Referencing a type in JavaScript is a data structure that is organized together. It is also often called a class, but there is no concept of class in JavaScript. Although JavaScript is an object-oriented language, it does not have the basic structure of classes and interfaces supported by traditional object-oriented languages.
How to create an array, there are three ways to create an array in the script:
1.new operator
var user = new Objcet ();
User.Name = "John";
user.age=20;
user.sex= "Male";
2. Object literal Volume
var user ={ name = "John", Age =, sex = "male"}
Note: When you create an object with a literal, it ends with "," but the last property is not followed by a comma.
3. Traditional complex ways
var user = {}; User.Name = "John"; User.age = 20; User.sex = "male";
How objects are invoked
There are two ways to invoke an object:
Method 1:
Alert (User.Name + "" +user.age); Return to ' Zhang 320 '
Method 2:
Alert (user[' name '] + "" +user[' age '); Return to ' Zhang 320 '
Add method
var user = {
name: "John",
age:20,
sex: "Male",
info:function () {
alert (THIS.N Ame+ "" +this.age+ "" +this.sex);
showhello:showhello//Add methods outside of object to object
}
functi On Showhello () {
alert ("hello!");
}
User.info (); Two methods of invocation
User.showhello ();