Skip to content

Instantly share code, notes, and snippets.

@JiaLiPassion
Last active July 10, 2018 03:08
Show Gist options
  • Save JiaLiPassion/b729181ba00d732bbc4446ac1743464e to your computer and use it in GitHub Desktop.
Save JiaLiPassion/b729181ba00d732bbc4446ac1743464e to your computer and use it in GitHub Desktop.
var ctx = {
data: 'data'
};
function callback() {
// access shared data from global variable.
console.log('callback invoked', ctx); // will be {data: 'onload data'}
}
window.onload = function() {
ctx.data = 'onload data';
setTimeout(callback, 100);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment