All things in JavaScript are objects: strings, numbers, arrays, functions ...
In addition, JavaScript allows custom objects to be customized.
JavaScript objects
JavaScript provides multiple built-in objects, such as String, Date, Array, and so on.
Objects are just special data types with properties and methods.
In ECMAScript, the physical representation of an object cannot be accessed, and only references to the object can be accessed. Every time you create an object, it is stored in a variable and is a reference to that object, not the object itself.
Local objects
ECMA-262 defines local objects (native object) as "objects provided by ECMAScript implementations that are independent of the hosting environment." In simple terms, a local object is a class defined by ECMA-262 (reference type). They include:
- Object
- Function
- Array
- String
- Boolean
- Number
- Date
- Regexp
- Error
- Evalerror
- Rangeerror
- Referenceerror
- SyntaxError
- TypeError
- Urierror
Built-in objects
ECMA-262 defines the built-in object (built-in object) as "all objects that are provided by the ECMAScript implementation, independent of the hosting environment, and appear when the ECMAScript program starts executing." This means that the developer does not have to instantiate the built-in object explicitly, it has been instantiated. ECMA-262 only defines two built-in objects, Global and Math (they are also local objects, by definition, each built-in object is a local object).
Host Object
All non-local objects are host objects (host object), which is the object provided by the hosting environment implemented by ECMAScript.
All BOM and DOM objects are host objects.
varobj ={a:{Name:"Maoguotao", Age:18, Sex:M,}, b:{name:"Maoshuqin", Age:18, Sex:M,}, c:{name:"MGT360124", Age:18, Sex:M, Title: {job:Monitor } } }; //recursively traverse an object vararr = []; functionf (obj) { for(varIinchobj) { if(typeofObj[i] = = = "Object") {f (obj[i]); }Else{Arr.push (obj[i]); }}} f (obj); Console.log (arr);//["Maoguotao", "M", "Maoshuqin", "M", "MGT360124", "M", "Squad Leader"]
JavaScript Objects---Recursive traversal of objects