+ 1

Can somebody explain me?

function person(name, age, color) { this.name = name; this.age = age; this.favColor = color; } in this function i can't understand that which are so definite function names that we can't change, and which are names we can call with another words.

3rd Sep 2016, 7:54 AM
Bekzod Erkinov
3 odpowiedzi
+ 2
In case of Objects: var object= objectName{ name:value;} we can call by objectName.value; //This is dot notation of calling object values objectName['value']; this is other method of calling. But here your refrence snippet is of object constructor function objName(name1,name2,name3){ this.name1=name1; this.name2=name2; this.name3=name3; } So take this as a stencil to draw something! So in tech terms its called a class. And class is blueprint of object. so now using that blueprint first we've assign values. like: var ex1=objName('you','me','them'); as the above line executes these values are placed as Objects. name1 being the name and given params being values. like 'you'. I hope this helps you. and please if any leet finds this wrong correct me :)
7th Sep 2016, 2:35 AM
Mohd.Tauheed Uddin Siddiqui
Mohd.Tauheed Uddin Siddiqui - avatar
+ 1
well maybe i cannot explain very well but I'll try the names with 'this' are function names and the parameters which is name,age and color in your code you can call it by another words. so if you have a code like: function dog(dogname,dogcolor,dogsize){ this.name=dogname; this.color=dogcolor; this.size=dogsize; } than you have to get the object dog named dog1's name like dog1.name but you cannot use dog1.dogname or it will return undifineded hope you understand :-)
4th Sep 2016, 1:06 PM
Nether_Deth
Nether_Deth - avatar
0
Thank you ! This kind of explanation is crucial to me.
4th Sep 2016, 1:11 PM
Bekzod Erkinov