Skip to content

Instantly share code, notes, and snippets.

@brianleroux
Created May 17, 2010 22:20
Show Gist options
  • Save brianleroux/404309 to your computer and use it in GitHub Desktop.
Save brianleroux/404309 to your computer and use it in GitHub Desktop.
// 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]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment