Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
setTimeout(function() {
var local = {
callback: function() {}
};
window.global = {
_eventListeners: [],
onChange: function(callback) {
this._eventListeners.push(callback);
}
};
// Using closure
global.onChange(function() {
local.callback();
});
// Using bind
global.onChange(local.callback.bind(local));
}, 5000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment