Skip to content

Instantly share code, notes, and snippets.

@chee
Last active August 28, 2018 09:49
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save chee/ece8272550e09f312a23 to your computer and use it in GitHub Desktop.
Save chee/ece8272550e09f312a23 to your computer and use it in GitHub Desktop.
// bizarguments is a v8 anomaly
function abc() {
return def();
}
function def() {
return abc.arguments[0] * 2;
}
abc(50); // >> 100
// so that's weird enough but:
function foo(arg) {
bar();
console.log(arg);
}
function bar() {
foo.arguments[0] = "lol";
}
foo("hello") // prints "hello"
// alright, so you can't edit the arguments up the stack
function foo(arg) {
bar();
// this line is the only thing that changes:
console.log(arg, arguments[0]);
}
function bar() {
foo.arguments[0] = "lol";
}
foo("hello") // prints "lol" "lol"
// wait what
// wait what twice
@chrisdickinson
Copy link

function foo(arg) {
  bar();
  return console.log(arg);

  // comment this out if YOU WANT TO LIVE
  arguments
}

function bar(args) {
  foo.arguments[0] = "lol";
}

foo("hello") // prints "lol" "lol"

// wait what
// wait what twice

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