Created
March 12, 2016 18:55
-
-
Save quanengineering/02397ccd85a776a66585 to your computer and use it in GitHub Desktop.
callback example
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
// 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