JS Shorthand - Object

There are six types in js : string, number, boolean, object, null, and undefined.

console.log(typeof "123");//string
console.log(typeof 123);//number
console.log(typeof true);//boolean
console.log(typeof {});//object
console.log(typeof null);//object
console.log(typeof undefined);//undefined

Among them, string, number, boolean, null, and undefined are called simple basic types , and object is an object type .

The most basic type of object is Object. Object has many sub-objects, such as String, Number, Boolean, Function, Array, etc. String, Number, and Boolean can be regarded as the packaging types of the basic types string, number, and boolean. The js engine automatically "packages" basic types into their corresponding object types if necessary during execution.

 Normally, all object types "inherit" Object objects, but there are exceptions:

var a1 = {};
var a2 = Object.create(null);

Looking at these two properties of window, a2 does not "inherit" the Object object:

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325212290&siteId=291194637
Recommended