0

Why is it that some method have parenthesis and some are not having. Examples: int[] arr= new arr[] arr.length arr.append()

Array

14th Feb 2022, 1:38 PM
Emmanuel Ojo
Emmanuel Ojo - avatar
3 odpowiedzi
+ 2
arr.length is data field. arr.append() is a method. When you have () in calling, then it is a method, otherwise it is a data. Mention the language name, which you refering... Also, it's possible to assign a function to a variable in some languages. As far I remember, in js, When you assigning a function to a variable, it's not need to add parenthesis. If you add there, then it call the function instead of assigning or making a alias..
14th Feb 2022, 2:17 PM
Jayakrishna 🇮🇳
+ 1
If I may ask what is the use of the parenthesis
14th Feb 2022, 2:25 PM
Emmanuel Ojo
Emmanuel Ojo - avatar
0
That makes a difference between it's data field and member method. Or a simple variable and a function.. according to syntax.
14th Feb 2022, 2:42 PM
Jayakrishna 🇮🇳