Home > Article > Web Front-end > A brief introduction to the Object type in js
This article brings you a brief introduction to the Object type in js. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
Objects in ECMAScript are actually a collection of data and functions. Created via the new operator followed by the name of the object type to be created.
//创建一个Object对象 var o = new Object();
Key:
The Object here is equivalent to the ancestor, and creating an instance of Object is of no use. It is like the java.lang.Object object in java.
Features:
Properties and methods common to each instance of the Object type:
Constructor: Saves the function used to create the current object.
hasOwnProperty: used to detect whether the given property exists in the instance of the current object.
isPrototypeOf: used to check whether the incoming object is the prototype of the current object
propertyIsEnumerble: used to check whether a given property can be enumerated using for-in
toLocaleString() : Returns the string representation of the object.
toString() : Returns the string representation of the object.
valueOf() : Returns the string, numerical value, or Boolean representation of the object. Usually the same value returned by toString().
Related recommendations:
Use js attributes to achieve the effect of horizontal drop-down menu in html5 (code)
Use template template engine in js An example of implementation (code)
The above is the detailed content of A brief introduction to the Object type in js. For more information, please follow other related articles on the PHP Chinese website!