Skip to content

Instantly share code, notes, and snippets.

@insin
Created July 10, 2011 03:11
Show Gist options
  • Select an option

  • Save insin/1074217 to your computer and use it in GitHub Desktop.

Select an option

Save insin/1074217 to your computer and use it in GitHub Desktop.
Yo dawg, I heard you like call() and apply()...
// Call apply() in the context of document.getElementById with the arguments: document, ['header']
Function.prototype.apply.call(document.getElementById, document, ['header'])
// Apply apply() in the context of document.getElementById with the arguments: document, ['header']
Function.prototype.apply.apply(document.getElementById, [document, ['header']))
// Call call() in the context of document.getElementById with the arguments: document, header
Function.prototype.call.call(document.getElementById, document, 'header')
// Apply call() in the context of document.getElementById with the arguments: document, header
Function.prototype.call.apply(document.getElementById, [document, 'header'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment