This file contains hidden or 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 Car() { | |
console.log(this); | |
console.log(this instanceof Car); | |
this.a = 'i am a '; | |
} | |
var t = new Car(); | |
var tt = Car(); | |
console.log(t); |
This file contains hidden or 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
/** | |
* 单例模式 | |
* 避免重复创建相同对象 | |
* example: | |
* let a = new TestClass(); | |
* let b = new TestClass(); | |
* a === b // false | |
* 如何a===b 为 true | |
*/ |
NewerOlder