Skip to content

Instantly share code, notes, and snippets.

@theJian
Created March 7, 2016 13:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theJian/5e6000ea23124cb4785f to your computer and use it in GitHub Desktop.
Save theJian/5e6000ea23124cb4785f to your computer and use it in GitHub Desktop.
pass arguments to callback function
function callback(a, b) {
return function() {
console.log('sum = ', (a+b));
}
}
var x = 1, y = 2;
document.getElementById('someelem').addEventListener('click', callback(x, y));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment