Here we will describe how to create a new object in JavaScript. It is very easy to create a new JavaScript Object in JavaScript. Although the functions inside JavaScript and the browser itself are very powerful, JavaScript still provides a method to create a new JavaScript Object.
Create an object in JavaScript
You can use JavaScript to create your own objects. Although the functions inside JavaScript and the browser itself are very powerful, JavaScript still provides a method to create a new JavaScript Object. So that it does not have to perform a lot of complex work as the hypertext mark language requires or other multimedia tools.
It is very easy to create a new JavaScript Object in JavaScript. First, it must define a JavaScript Object and then create an instance for the JavaScript Object. This example is a new JavaScript Object with basic features in the JavaScript Object definition.
I. JavaScript Object Definition
The basic format of JavaScriptJavaScript object is as follows:
- FunctionObject Attribute Table)
-
- This. prop1 = prop1
-
- This. prop2 = prop2
-
- ...
-
- This. meth = FunctionName1;
-
- This. meth = FunctionName2;
-
- ...
In the definition of a JavaScript Object, you can specify its attributes and methods for this JavaScript Object. A JavaScript object instance is composed of attributes and methods. The following is a definition of the UniversityJavaScript object:
- Functionuniversity(name,city,creatDateURL)
-
- This.name=name
-
- This.city=city
-
- This.creatDate=NewDate(creatDate)
-
- This.URL=URL
-
Its basic meaning is as follows:
Name-specify a "unit" Name.
City-the City in which the Unit is located.
CreatDate-specifies the update date of the universityJavaScript object.
URL-This JavaScript Object points to a URL.