0
What is the difference between objects and variable in javascript?
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")
0
thanx Nicholas