js内置对象-Object

1)Object构造函数的方法

返回指定对象的原型对象

Object.getPrototypeOf(mymap);     
/*{featureStyle: {…}, selfLayersCount: null, openedMapIds: null, openedMapInfos: null, allLayerInfos: null, …}
  CLASS_NAME:"MapSystem.Map.SmMap"
  addLayerCompleted:ƒ (data)
*/

2)Object实例和Object原型对象的方法

hasOwnProperty:判断某个对象是否有指定的私有属性
1)
var t = {"name":"zhangsan","year":23,"gender":"man"}; t.hasOwnProperty("name") //true t.hasOwnProperty("value") //false
2)
"name" in t; //true
"sex" in t; //false
3)
var fn = function() {};
fn.prototype.name = "zhangsan";
var f = new fn();
f.name; //"zhangsan"
f.hasOwnProperty("name") //因为f没有私有属性,所以是false
 

3)constructor

constructor是默认指向创建当前对象的构造函数,如果原型prototype被修改了,那么实例的constructor也变了。

4)

实例上的__proto__就是指向原型上的prototype。

原文地址:https://www.cnblogs.com/jiktiv123/p/8315346.html