Home  >  Article  >  Web Front-end  >  What is obj in js

What is obj in js

anonymity
anonymityOriginal
2019-05-29 14:49:469477browse

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.

What is obj in js

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn