Skip to content

Instantly share code, notes, and snippets.

@quanengineering
Created March 12, 2016 18:55
Show Gist options
  • Save quanengineering/02397ccd85a776a66585 to your computer and use it in GitHub Desktop.
Save quanengineering/02397ccd85a776a66585 to your computer and use it in GitHub Desktop.
callback example
// global variable
var allUserData = [];
function logStuff (userData) {
console.log('22222222');
if ( typeof userData === "string")
{
console.log(userData);
}
else if ( typeof userData === "object")
{
for (var item in userData) {
console.log(item + ": " + userData[item]);
}
}
console.log('3333333');
}
function getInput (options, callback) {
console.log('11111111111');
allUserData.push (options);
callback (options);
}
getInput ({name:"Rich", speciality:"JavaScript"}, logStuff);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment