Created
November 21, 2013 15:55
-
-
Save dickeylth/7584184 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset=utf-8 /> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Person(){ | |
// 缓存实例 | |
var instance = this; | |
// 添加属性 | |
this.attr = "Attribute"; | |
// 重写该构造函数 | |
Person = function(){ | |
return instance; | |
}; | |
} | |
Person.prototype.job = 'FE'; | |
var p1 = new Person(); | |
Person.prototype.city = 'Beijing'; | |
var p2 = new Person(); | |
console.log(p1); | |
console.log(p2); | |
console.log(p1.constructor === Person); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment