Home>Article>Web Front-end> How javascript objects are defined

How javascript objects are defined

王林
王林 forward
2020-05-27 17:28:43 2904browse

How javascript objects are defined

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 objects.

JavaScript uses a {...} to represent an object, and the key-value pair is declared in the form xxx: xxx, separated by,.

Example:

var 对象名字={ 属性 方法  };

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 information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete