Created
October 13, 2010 09:51
-
-
Save honjo2/623769 to your computer and use it in GitHub Desktop.
[js] newし忘れても問題ない擬似クラス
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 Waffle() { | |
if (!(this instanceof arguments.callee)) { | |
return new arguments.callee(); | |
} | |
this.tastes = "yummy"; | |
} | |
Waffle.prototype.wantAnother = true; | |
var first = new Waffle(); | |
var second = Waffle(); | |
console.log(first.tastes); // yummy | |
console.log(second.tastes); // yummy | |
console.log(first.wantAnother); // true | |
console.log(second.wantAnother); // true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment