Skip to content

Instantly share code, notes, and snippets.

@AndreasMadsen
Created October 27, 2012 18:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndreasMadsen/3965647 to your computer and use it in GitHub Desktop.
Save AndreasMadsen/3965647 to your computer and use it in GitHub Desktop.
Hack javascript - delete
var log = typeof print === 'undefined' ? console.log : print;
// get v8 internal DELETE
var DELETE;
delete ({}[{ toString: function x(){ DELETE = x.caller; } }]);
// try it out
var obj = {hi: true};
DELETE.call(obj, 'hi', 0); // BUG: hack.js:5: RangeError: Maximum call stack size exceeded
// print obj
log(obj.hasOwnProperty('hi') === false); // should print true
@AndreasMadsen
Copy link
Author

@Benvie wounded if you could explain this.

I have executed the hack.js with both d8 and node and I get the same result:

RangeError: Maximum call stack size exceeded error.

Expected result that true is printed.

The source is primally copied from your blog.

In any case, Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment