var a = {};
//Firefox and Chrome
Object.getPrototypeOf(a);
//Firefox , Chrome and Safari
//
a.__proto__; //[Object Object]
// all browsers
a.constructor.prototype; //[Object Object];
var A = function(a){
this. a = a;
}
var a = new A("1");
a.__proto__ == A.prototype; // true
a instanceof A; // true
一些内置方法:
isPrototypeOf : 用于检查某对象是否是用当前构造器创建的
function Game(){}
var game = new Game();
Game.isPrototypeOf(game); // true
game instanceof Game; // true
hasOwnProperty() : 用于检查某属性是不是当前对象自带的(非继承的)
function Game(){
this.name = "2048";
}
Game.prototype.age = 20;
var game = new Game();
game.hasOwnProperty('name'); // true
game.hasOwnProperty('age'); // false