Last active
August 4, 2017 21:58
-
-
Save naganowl/93dfa9de0d517022c342b0b86d8d2a41 to your computer and use it in GitHub Desktop.
Applying a call in JS
This file contains 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
// 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