+ 2

//How to call the function "yearOfBirth" person.yearOfBirth //or person.yearOfBirth()

?

24th Mar 2020, 3:06 PM
Ajit Kumar Jena
Ajit Kumar Jena - avatar
2 odpowiedzi
+ 2
If it is a function, you use parenthesis to call it. If you are assigning it as callback, then you don't use parenthesis.
24th Mar 2020, 3:14 PM
Gordon
Gordon - avatar
+ 3
Considering that person is a reference to an object of a class. You can call it by person.yearOfBirth(); Also you can use the code playground to run and see it for yourself.
24th Mar 2020, 3:16 PM
Avinesh
Avinesh - avatar