Created
June 18, 2012 13:27
-
-
Save jbeard4/2948362 to your computer and use it in GitHub Desktop.
This illustrates how JScript.NET fails to extend intrinsic object 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
//jscript.net does not support extending intrinsic object prototypes | |
Object.prototype.foo = 1; | |
var x = {}; | |
print("Object.prototype.foo -",Object.prototype.foo); //should print 1. in jscript.net: undefined | |
print("x.foo - ",x.foo); //same | |
Object.prototype["foo"] = 1; | |
var y = {}; | |
print("Object.prototype.foo - ",Object.prototype.foo); //same | |
print("x.foo - ",x.foo); //same | |
print("y.foo - ",y.foo); //same | |
try { | |
Array.prototype.bar = 2; //this blows up | |
}catch(e){ | |
print("Exception :",e.message); | |
} | |
try { | |
Array.prototype["bar"] = 2; //this blows up | |
}catch(e){ | |
print("Exception :",e.message); | |
} | |
var z = []; | |
print("z.bar - ",z.bar); //undefined | |
print("Array.prototype.bar - ",Array.prototype.bar); //undefined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment