0
in this example the word new why we used it?
object constructor
7 Answers
+ 3
when we want to declare for example new object, array ...
example:
var obj = new Object(); -----> creating object
var array= new Array() ------> creating array
:)
+ 3
because p1 and p2 are new person, and they inherit a preporties from person :) p1 and p2 are objects who inherit a preporties from object person .
+ 3
Nothing đ
+ 1
I understand now
thanks a lotđđđđ
+ 1
really help me a lotđđđ
thank you
0
which example?
0
unction person(name, age, color) {
this.a = name;
this.b = age;
this.c = color;
}
var p1 = new person("John", 42, "green");
var p2 = new person("Amy", 21, "red");
document.write(p1.b);
document.write(p2.a);