0
is it neccesssary to use the same formate as we taken in the function.
function person(name, age, color) { this.name = name; this.age = age; this.favColor = color; } var p1 = new person("John", 42, "green"); var p2 = new person("Amy", 21, "red"); document.write(p1.age); document.write(p2.name); is it neccesssary to use the same formate as we taken in the function. function person(name,age,color) to declare in, var p1 = new person("John", 42, "green");
2 Respuestas
+ 1
suppose you didnt use the format you set and put var p1 = new person (30, "blue", "Ted") it would try to put 30 as a name blue as a number and ted as a color
0
this is because of javascripts left to right associtivity when it passes these variables to the function