is it neccesssary to use the same formate as we taken in the function. | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
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");

14th Dec 2016, 1:30 PM
HARISH BATTULA
HARISH BATTULA - avatar
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
14th Dec 2016, 4:15 PM
Cory Clapp
Cory Clapp - avatar
0
this is because of javascripts left to right associtivity when it passes these variables to the function
14th Dec 2016, 4:17 PM
Cory Clapp
Cory Clapp - avatar