- 3

Why

Why when we use a function like this》function person (name, age) { this.name=name; this.age=age; 》》 and then they used 》this.yearofbirth=birthyear 》 why name and age was set between () by function and birth year not ?

20th Feb 2017, 11:56 AM
tareq
tareq - avatar
1 Antwort
0
if you declare and initialize birthyear variable in the global scope then no need to pass that variable as a parameter.you get the access of birthyear inside the function.
21st Feb 2017, 1:54 AM
Ekhlasur Rahman
Ekhlasur Rahman - avatar