+ 19

In simple language tell me what you understand in this adding method code for me to underdtand easily?

function person(name, age) { this.name= name; this.age = age; this.yearOfBirth = bornYear; } function bornYear() { return 2016 - this.age; } var p = new person("A", 22); document.write(p.yearOfBirth());

18th Feb 2018, 6:59 PM
Daniel Belay Akele
Daniel Belay Akele - avatar
1 ответ
+ 13
you can define object property to be function that is defined outside constructor and you can call that function with property name associated with function, no with function name
19th Feb 2018, 12:21 AM
Vukan
Vukan - avatar