First of all, an object is also a variable, but an object can contain multiple variables. Objects are containers for variables.
Use the var keyword to define an object.
Javascript uses a {…} to represent an object, and the key-value pair is declared in the form of xxx: xxx, separated by .
Example:
var object name={ Attributes method };
Summary
1. Remember the semicolon after the curly braces;
2. Separate each attribute with a comma.
Recommended tutorial: js introductory tutorial
The above is the detailed content of how Javascript objects are defined. For more, please pay attention to other related articles on 1024programmer.com!