Last active
December 10, 2015 05:29
-
-
Save Dragory/4387946 to your computer and use it in GitHub Desktop.
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() { | |
var foo = { | |
'foo': 5, | |
'bar': function() { | |
console.log('a'); | |
} | |
}; | |
var bar = function() { | |
this.foo = 5; | |
}; | |
bar.prototype.bar = function() { | |
console.log('a'); | |
}; | |
var thing = function() { | |
this.foo = 5; | |
}; | |
thing.bar = function() { | |
console.log('a'); | |
}; | |
// var a = new foo; // Syntax error | |
var b = new bar; // Works | |
var c = new thing; // Works | |
console.log(b.bar); // function () { console.log('a'); } | |
console.log(c.bar); // undefined | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment