Created
May 12, 2010 18:43
-
-
Save brianleroux/398962 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
alert.call.call.call.call.call.apply(function (a) {return a}, [1,2]) // 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
// this is just a really silly way of saying this
Function.prototype.call.apply(function (a) {return a}, [1,2])
// 2
// if this still seems weird to you. Consider this:
function logThisAndArgs(){ console.log(this, arguments); }
Function.prototype.call.apply(logThisAndArgs, [{'some':'object'},1,2,3,4])
// logs -> Object { some="object"} [1, 2, 3, 4]
// or this
Function.prototype.call.call(logThisAndArgs, {'some':'object'},1,2,3,4)
// logs -> Object { some="object"} [1, 2, 3, 4]