Skip to content

Instantly share code, notes, and snippets.

@satyr
Created May 9, 2011 14:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save satyr/962661 to your computer and use it in GitHub Desktop.
Save satyr/962661 to your computer and use it in GitHub Desktop.
`Object.create(null)` for JScript
// `Object.create(null)` for JScript.
// Based on @bga_'s SafeJS.
NullObject = (function(){
var doc = new ActiveXObject('htmlfile')
doc.write('<script><\/script>')
doc.close()
var Obj = doc.parentWindow.Object
if(!Obj || Obj === Object) return
var name, names =
[ 'constructor', 'hasOwnProperty', 'isPrototypeOf'
, 'propertyIsEnumerable', 'toLocaleString', 'toString', 'valueOf']
while(name = names.pop()) if(!delete Obj.prototype[name]) return
return Obj
}())
!function(){
var toString = 1
with(new NullObject) WSH.echo(toString)
}()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment