+ 1

What does the "new" mean in the example of adding methods??

p = new function_name()

18th Apr 2017, 2:31 PM
Alan Chan
Alan Chan - avatar
3 odpowiedzi
0
function person(name, age) { this.name= name; this.age = age; this.yearOfBirth = bornYear; } var p = new person("A", 22); "new" is used to create a new instance of the person object and assigns it to "p" variable. The result is: p.name is initialized to "A" p.age is initialized to 22
18th Apr 2017, 6:35 PM
Simon Obute Obute
Simon Obute Obute - avatar
0
p = new function_name() "new" creates an instance of function_name object "=" is used to assign the created instance of function_name to "p"
18th Apr 2017, 6:39 PM
Simon Obute Obute
Simon Obute Obute - avatar
0
What is it betwen x and 2
18th Apr 2017, 8:49 PM
Filip
Filip - avatar