-
-
Save theJian/5e6000ea23124cb4785f to your computer and use it in GitHub Desktop.
pass arguments to callback function
This file contains 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
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