————————————————————————————————
<script type= "Text/javascript" >
The simplest way to create objects, surrounded by a pair of curly braces.
var obj001 = {}; Use curly braces to create an object with empty content
OBJ001.PROP1 = 100; Add an attribute Prop1 to the object, assigning a value of 100
OBJ001.PROP2 = function () {//Adds a method prop2 for the object and provides an implementation
Alert (' I am Method 001 '); Provide an alert statement
};
OBJ001.PROP2 (); Methods for calling Objects
Create an object using function
function createObj002 () {//declares a function that creates an object, similar to the class
THIS.PROP1 = 200; Declares an attribute Prop1
THIS.PROP2 = function () {//Declare a method PROP2
Alert (' I am Method 002 ');//provide an alert statement
};
};
var obj002 = new createObj002 ();//Create a Obj002 object
OBJ002.PROP2 (); Call the Prop2 method of the Obj002 object
Create an object in the form of a new object ()
var obj003 = new Object ();
OBJ003.PROP1 = 300; Set Property Prop1
OBJ003.PROP2 = function () {//Adds a method prop3 for the object and provides an implementation
Alert (' I am method 003 '); Provide an alert statement
};
OBJ003.PROP2 (); Calling methods
</script>
——————————————————————————————————————
Objects and arrays-creating custom objects