Skip to content

Instantly share code, notes, and snippets.

View MrKou47's full-sized avatar

Bo Kou MrKou47

View GitHub Profile
@MrKou47
MrKou47 / new_ identifier.js
Created July 28, 2017 04:24
关于js new 标识符的一些点
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);
@MrKou47
MrKou47 / singleton_pattern.js
Last active July 28, 2017 03:57
单例模式
/**
* 单例模式
* 避免重复创建相同对象
* example:
* let a = new TestClass();
* let b = new TestClass();
* a === b // false
* 如何a===b 为 true
*/