标签:就是 col cal func created person javascrip new 创建
created on 21/03/04
function Person(color){
console.log(this);
this.color = color;
this.getColor = function(){
console.log(this);
return this.color;
};
this.setColor = function(color){
console.log(color);
this.color = color;
};
}
Person("red"); //window
var p = new Person("yello"); //p
p.getColor(); //p
var obj = {};
p.setColor.call(obj, "black"); //obj
var test = p.setColor;
test(); //window
标签:就是 col cal func created person javascrip new 创建
原文地址:https://www.cnblogs.com/PHY01/p/14958377.html