Created
January 4, 2010 14:49
-
-
Save subtleGradient/268551 to your computer and use it in GitHub Desktop.
CommonJS: Module instances of global objects share prototypes?
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
var myString1 = require('commonjs_mod').myString; | |
var myString2 = "app"; | |
myString1.foo(); // no Fail. This string is an instance of a String whose prototype has a `foo` method | |
myString2.foo(); // Fail. This string is an instance of the global String native |
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
String.prototype.foo = function(){ return "foo'd"; }; | |
exports.myString = "mod"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment