Last active
August 29, 2015 14:06
-
-
Save eoinkelly/bf0e97002f4ebb02cded to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// I am confused about how you can use `call` without supplying an object for `this` | |
// The docs don't indicate that you can: | |
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call | |
var funny = function (a) { return (a + 3); } | |
funny(3); // 6 | |
funny.call({},3); // 6 | |
funny.call(3); // NaN // (as expected) | |
var xs = [1,2,3] | |
var pop = Array.prototype.pop; | |
pop.call(xs); // 3 // Why does this work ... | |
pop.call({}, xs); // undefined // ... but this does not? | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ah OK so I was misinterpreting
pop
as a "pull the last thing off the given array" when it is really "pull that last thing off the array you are attached to". Seems obvious in retrospect - thanks @chilts!