0

What is the difference between objects and variable in javascript?

16th Dec 2016, 10:27 AM
TechBeat
TechBeat - avatar
2 Respuestas
+ 3
Objects can hold many values (properties). var pencil = "wood". In this case, 'pencil' is a variable, but not an object. var pencil = {material: "wood", type: "stationery"}. In this case, 'pencil' is more of an object. An object is like an array of values, where you can get one of its members. Such as with document.write(pencil.type) will give "stationery". Similarly, you can do document.write(pencil[1]) on var pencil = new Array("wood", "stationery")
16th Dec 2016, 10:52 AM
David Sebastian Keshvi Illiakis
David Sebastian Keshvi Illiakis - avatar
0
thanx Nicholas
16th Dec 2016, 12:45 PM
TechBeat
TechBeat - avatar