Home >Web Front-end >JS Tutorial >What is obj in js
JavaScript variables are containers of data values.
This code assigns a single value (porsche) to a variable named car:
var car = "porsche";
Objects are also variables. But objects contain many values.
This code assigns multiple values (porsche, 911, white) to a variable named car:
var car = {type:" porsche", model:"911", color:"white"};
Values are written in name:value pairs (name and value are separated by colon).
JavaScript objects are containers of named values
obj To put it bluntly, it is document.getElementById(whichlink "menu")
This is equivalent to assigning the value of document.getElementById(whichlink "menu") to a variable in obj
Accessing object properties
You can access in two ways Attribute:
objectName.propertyName
or
objectName["propertyName"]
The above is the detailed content of What is obj in js. For more information, please follow other related articles on the PHP Chinese website!