Home > Web Front-end > JS Tutorial > A brief introduction to the Object type in js

A brief introduction to the Object type in js

不言
Release: 2018-08-13 16:28:13
Original
2119 people have browsed it

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.

Object type

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();
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template