Created
December 19, 2012 02:29
-
-
Save fxxkscript/4333865 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
//自调用构造函数 | |
function Waffle() { | |
if (!(this instanceof Waffle)) { | |
return new Waffle(); | |
} | |
this.tastes = "yummy"; | |
} | |
var first = new Waffle(), | |
second = Waffle(); | |
console.log(first.tastes); | |
console.log(second.tastes); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment