Copy Code code as follows:
function ForEach (o) {
var html = "";
for (var i in O) {
HTML + i+ "=" +o[i]+ "";
}
Console.log (HTML);
Console.log (o);
}
1
Object.create (Proto)
Object.create (proto,descriptors)
Creates an object using the specified prototypes and properties
Parameters:
Proto: A prototype of a newly created object that can be null
Descriptors: An optional object that maps the property name to the attribute descriptor
Returns a newly created object that inherits from the Proto and owns the descriptors of the second-rate property.
Copy Code code as follows:
var obj = object.create ({x:1,y:2},{
Z:{value:3,writable:true,enumerable:true,configurable:true}
});
ForEach (obj)
Obj.z=5
Console.log (obj)
Console.log ("=====================================================")
2
Object.defineproperties (o,descriptors)
Create or configure multiple properties of an object
Parameters:
O: The object on which to create or configure the property
Descriptors: An object that maps an attribute name to an attribute descriptor
Return Object o
Copy Code code as follows:
Object.defineproperties (obj,{
A:{value: "A", writable:false,enumerable:true,configurable:true},
B:{value: "B", writable:false,enumerable:true,configurable:true}
})
ForEach (obj);
Console.log ("=====================================================")
3
Object.defineproperty (O,NAME,DESC)
Create or configure a property of an object
Parameters:
O: The object on which the property will be created or configured
Name: property names that will be created or configured
Desc: A Property Descriptor object that describes the new property to be created or the modification of an existing property
Return Object o
Copy Code code as follows:
Object.defineproperty (obj, "C", {value: "C", writable:false,enumerable:false,configurable:true})
ForEach (obj);
Console.log ("=====================================================")
4
Object.freeze (o)
Make an object immutable and does not affect inherited properties
Parameters:
O: Objects to be frozen
Back to True|false
Copy Code code as follows:
var p = {X:1,y:2}
Object.freeze (P);
p.x = 2;
Console.log (P);
Console.log (Object.isfrozen (p))//true, once frozen cannot thaw
Console.log ("=====================================================")
5
Object.getownpropertydescriptor (O,name)
Parameters:
O: An Object
Name: Property name to query
Querying attributes of an attribute
Returns a property descriptor object for the specified property of an object, or returns undefined if no specified property exists.
/*
A property descriptor is an ordinary JavaScript object that describes the attributes of an object and has two JavaScript properties. The data attribute has a value and three properties: Enumerable (Enumerable),
Writable (writable), and configurable (configurable). Accessor properties (accessor property) have a getter and/or setter method, as well as enumerable.
Descriptor for Data property:
{
Value: Any JavaScript value,
Writable:true|false,
Enumerable:true|false,
Configurable:true|false
}
Descriptor for accessor properties:
{
Get:function or undefined: replacing attribute values
Set:function or undefined: replace writable
Enumerable:true|false,
Configurable:true|false
}
*/
Copy Code code as follows:
var o5 = object.getownpropertydescriptor (obj, "C");
Console.log (O5);
ForEach (O5);
Console.log ("=====================================================")
6
Object.getownpropertynames (o)
Returns the name of a non-inherited property
Parameters:
O: An Object
Returns the names of all the non-inherited properties that contain O, including which are not enumerable properties. {Enumerable:false}
Copy Code code as follows:
var O6 = object.getownpropertynames (obj);
Console.log (O6);
Console.log ("=====================================================")
7
Object.getprototypeof (o)
Parameters:
O: An Object
Returns the prototype of an object
Copy Code code as follows:
var o7 =object.getprototypeof (obj);
Console.log (O7);
Console.log ("=====================================================")
8
Object.hasownproperty (propname);
Parameters:
PropName A string containing the property name of the object
Checks whether a property is inherited
Back to True|false
Copy Code code as follows:
Console.log (Obj.hasownproperty ("X")); =>false
Console.log (Obj.hasownproperty ("z")); =>true
Console.log ("=====================================================")
9
Object.isextensible (o);
Determines whether new properties can be added on an object
Parameters:
O: Objects to be checked for extensibility
Returns can be added as true| cannot be false
Description: All objects are extensible when they are created, until they are passed into Object.preventextensions (o) object.seal (o) or Object.freeze (o);
Copy Code code as follows:
Console.log (object.isextensible (obj)); =>true
Object.preventextensions (obj)/set it to be not extensible
Console.log (object.isextensible (obj)); =>false
Console.log ("=====================================================")
10
Object.isfrozen (o)
Determine if an object is not immutable
Parameters:
O: Objects to be examined
True if O is frozen, or false;
Copy Code code as follows:
Console.log ("=====================================================")
11
Object.isprototypeof (o)
To determine whether the current object is a prototype of another object
Parameters:
O: All objects
True if the object is an O prototype, or False if O is not an object or if the object is not O.
Copy Code code as follows:
var o = new Object ();
Object.prototype.isPrototypeOf (o)//True
Array.prototype.isPrototypeOf ([1,2])//true;
Object.prototype.isPrototypeOf (Function.prototype)//true
Console.log ("=====================================================")
12
Object.issealed (o)
Determines whether an object's properties can be added or deleted
Parameters:
O: Objects to be examined
True if O is closed, or false.
If you cannot add a new (not inherited) property to an object, and the existing (not inherited) attribute cannot be deleted, it is closed.
The usual way to close an object is Object.seal (o) or Object.freeze (o)
Console.log ("=====================================================")
13
Object.keys (o)
Returns the name of a free enumerable property
Parameters:
O: An Object
Copy Code code as follows:
Console.log (Object.keys ({x:1,y:2}))//=>[x,y]
Console.log ("=====================================================")
14
Object.preventextensions (o)
Prevent the addition of new properties on an object
Parameters:
O: To set the Extensible object
Once it is set to be extensible, it can no longer be changed to extensible
Console.log ("=====================================================")
15
Object.propertyisenumerable (propname)
Detects whether a property is looping through for/in
Parameters
PropName: A string containing the specified property name of the object
Returns True if the object has a PropName property named, and the property can be enumerated.
Copy Code code as follows:
var o15 = new Object ();
o15.x = 15;
O15.propertyisenumerable ("X"); True
O15.propertyisenumerable ("Y"); False
O15.propertyisenumerable ("toString"); False
Console.log ("=====================================================")
16
Object.seal (o)
Block properties of an object from being added or deleted
Parameters
O: Objects to be closed
Returns the Parameter object o in the enclosing state
17
Object.tolocalestring ()
Returns the localized string indication of the object's local
The default toLocaleString () method provided by the object class is simply a call to the ToString () method.
Note, however, that other classes (Array, Date, number, and so on) each define their own version of this method. Used to perform localized string conversions. You may also need to overwrite this method when defining your own class.
18
Object.ToString ()
Defines a string representation of an object
Call ToString () methods that are not normally displayed in JavaScript programs. In general, this method is defined in an object and is called automatically when needed to replace the object with a string.
19
Object.valueof ()
The original value of the given object
Returns the original value associated with the specified object, if such a value exists, and returns the object itself if there is no value associated with the modified object