Local object: ECMA-262 The Local object (native object) as "the object provided by ECMAScript implementation independent of the hosting environment." In a nutshell, a local object is a ECMA-262-defined class (reference type) built-in object: ECMA-262 defines the built-in object (built-in objects) as "all objects that are provided by the ECMAScript implementation, independent of the hosting environment, in ECMASCR When the IPT 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. Enumerables = [' hasOwnProperty ', ' valueOf ', ' isprototypeof ', ' propertyisenumerable ', ' tolocalestring ', ' toString ', ' Constructor '];//hasOwnProperty: is used to determine whether an object has a property or object that you give a name to. However, it is important to note that this method cannot check whether the object has this property in its prototype chain, and that the property must be a member of the object itself. Dom is not supported under Ie8. hasOwnProperty method. isPrototypeOf is used to determine whether the object whose prototype chain is to be checked exists in the specified object instance, or True, otherwise returns false. 1, hasOwnProperty function: is used to determine whether an object has you give the name of the property or object. Invocation method: Object.hasownproperty (proname) parameter: an instance of an object (must), proname (must) a string value of a property name Note: If object has a property with the specified name, the The hasOwnProperty method returns True, otherwise false is returned. This method does not check the properties in the object's prototype chain. The property must be a member of the object itself. This property is not supported for host objects with Internet Explorer 8 and versions below it. Code liftExample: In the following example, all String objects share a common split method. The following code will display false and true. var s = new String ("Sample"); Console.log (S.hasownproperty ("split")); Console.log (String.prototype.hasOwnProperty ("split")); 2, in operator: Tests whether an attribute exists in an object. Invocation Mode: Result = Property in Object argument: result (must) any variable; proname (must) evaluates to an expression of string expression; object (must) any object note: The In operator determines whether the object is named Property's properties. It also determines whether the property is part of the object's prototype chain. code example: Code1:var myObject = new Object (); Myobject.name = "James"; Myobject.age = "22"; Myobject.phone = "555 0234"; if ("Phone" in MyObject) {Console.log ("present"); } else {Console.log ("property was not present"); } code2:console.log ("ToString" in "Zheyang"); Console.log ("ToString" in New String ("Zheyang") thinking: var aa = "Zheyang" differs from AA = new string ("Zheyang") 3, ValueOf effect: return Returns the original value of the specified object. Call mode: Object.valueof (); Note: In JS, the numbers are actually floating point. code example: var AA = 123 Console.log (aa.valueof ()) Console.log (123.valueOf ()) Console.log (123..valueOf ())Console.log ((123). ValueOf ()) 4, typeof effect: Returns the type of the specified object. Call mode: typeof object; code example: var AA = 12; var bb = new Number (Console.log) (typeof aa) Console.log (typeof bb) 5, instanceof Effect: Returns a Boolean value that indicates whether an object is an instance of a particular class or constructor. Call Mode: Object instanceof class, argument: Object (must) an objects, class (must) any object class or constructor; Note: If object is an instance of class or constructor, the instanceof operator returns TRU E. Returns False if object is not an instance of the specified class or function, or if object is null. JavaScript object is special, and objects are treated as instances of object only when they are constructed with the object constructor. code example: function ClassA () {} function ClassB () {} Classb.prototype = {Constructor:classa} function ClassC () {classa.call (this); } function Classd () {} var obj = new ClassA var obj2 = new ClassB; var obj3 = new ClassC; Classd.prototype = Obj2; var obj4 = new Classd; Console.log (obj instanceof ClassA) console.log (obj2 instanceof ClassB) console.log (obj2 instanceof ClassB) Consol E.log (obj3 instanceof ClassA) console.log (obj4 instanceof ClassA) Console.log (ClassA instanceof function) 6, isprototypeof effect: Determines whether an object exists in the prototype chain of another object. Invocation method: Prototype.isprototypeof (object) Parameter: prototype (must) object prototype, and object (must) another, will check its prototype chain NOTE: If object has a prototype in the prototype chain , the isPrototypeOf method returns True. A prototype chain is used to share functionality between different instances of the same object type. The isPrototypeOf method returns False when object is not an object or when prototype does not appear in the prototype chain of object. code example: function Rectangle () {} var rec = new Rectangle (); Cosole.log (Rectangle.prototype.isPrototypeOf (REC)); 7, propertyIsEnumerable effect: Returns a Boolean value, This value indicates whether the specified property is part of an object and whether the property is enumerable. Invocation method: Object.propertyisenumerable (propname) Parameter: object instance (required), propname (must) a string value for a property name; Note: If propname exists in object And you can use a for ... In the Loop enumeration, the propertyIsEnumerable property returns True. The propertyIsEnumerable property returns False if object does not have a property of the specified name, or if the specified property is not enumerable. In general, predefined properties are not enumerable, and user-defined properties are always enumerable. The propertyIsEnumerable property does not take into account objects in the prototype chain. code example: var a = new Array ("Apple", "banana", "cactus"); var s = a.propertyisenumerable (1); Console.log (s); 8, tostring/tolocalestring function: You can convert an object to a string and return the result. Call mode: Object.ToString (nUM) Parameter: Object (required), NUM (not required); Note: If the object is a number of children, the argument can be the number of digits to be converted, and the default is 10 if it is a Boolean type, it is converted to the corresponding string code example: var AA = 123 Console.log (Aa.tostring (2)) var bb = new Boolean (true) Console.log (BB) 9, constructor code example: Constructor.parent 10, Function and OBJEC Tfunction: First review the concept of function objects, functions are objects, the objects that represent functions are function objects. All function objects are constructed by the function object. In other words, the function is the topmost constructor. It constructs all the objects in the system, including user-defined objects, system built-in objects, and even its own. This also indicates that the function has a bootstrap (self-structuring capability). This also indirectly determines that the function's [[Call]] and [[constructor]] logic are the same. Object: For object, which is the topmost object, all objects inherit the prototype of object, but you also have to know explicitly that object is a function object, so object is constructed by function. code example: alert (function instanceof function),//true alert (function Instanceof object),//true alert (object instanceof funct ion);//true function foo () {};var foo = new Foo (); alert (foo instanceof foo); Truealert (foo instanceof Function); Falsealert (foo instanceof Object); Truealert (Foo instanceof Function); Truealert (Foo instanceof Object); True
A summary and usage of some of JavaScript's underlying methods