Skip to content

Instantly share code, notes, and snippets.

@naganowl
Last active August 4, 2017 21:58
Show Gist options
  • Save naganowl/93dfa9de0d517022c342b0b86d8d2a41 to your computer and use it in GitHub Desktop.
Save naganowl/93dfa9de0d517022c342b0b86d8d2a41 to your computer and use it in GitHub Desktop.
Applying a call in JS
// Invoke the first argument (needs to be a function), with `1` as the `this` context and `2` as the argument
console.log.call.apply(a => a, [1, 2]) // -> 2
console.log.call.apply(function(a,b) { return this.ab + a + b; }, [{ab: 19}, 2, 3]) // -> 24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment