+ 2
//How to call the function "yearOfBirth" person.yearOfBirth //or person.yearOfBirth()
?
2 ответов
+ 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.
+ 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.