Created
April 12, 2015 15:41
-
-
Save asith-w/30821ccda34873cd32d3 to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/zoricufaki
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
// global variable | |
var allUserData = []; | |
// generic logStuff function that prints to console | |
function logStuff (userData) { | |
if ( typeof userData === "string") | |
{ | |
console.log(userData); | |
} | |
else if ( typeof userData === "object") | |
{ | |
for (var item in userData) { | |
console.log(item + ": " + userData[item]); | |
} | |
} | |
} | |
// A function that takes two parameters, the last one a callback function | |
function getInput (options, callback) { | |
allUserData.push (options); | |
callback (options); | |
} | |
// When we call the getInput function, we pass logStuff as a parameter. | |
// So logStuff will be the function that will called back (or executed) inside the getInput function | |
getInput ({name:"Rich", speciality:"JavaScript"}, logStuff); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">// global variable | |
var allUserData = []; | |
// generic logStuff function that prints to console | |
function logStuff (userData) { | |
if ( typeof userData === "string") | |
{ | |
console.log(userData); | |
} | |
else if ( typeof userData === "object") | |
{ | |
for (var item in userData) { | |
console.log(item + ": " + userData[item]); | |
} | |
} | |
} | |
// A function that takes two parameters, the last one a callback function | |
function getInput (options, callback) { | |
allUserData.push (options); | |
callback (options); | |
} | |
// When we call the getInput function, we pass logStuff as a parameter. | |
// So logStuff will be the function that will called back (or executed) inside the getInput function | |
getInput ({name:"Rich", speciality:"JavaScript"}, logStuff);</script></body> | |
</html> |
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 = []; | |
// generic logStuff function that prints to console | |
function logStuff (userData) { | |
if ( typeof userData === "string") | |
{ | |
console.log(userData); | |
} | |
else if ( typeof userData === "object") | |
{ | |
for (var item in userData) { | |
console.log(item + ": " + userData[item]); | |
} | |
} | |
} | |
// A function that takes two parameters, the last one a callback function | |
function getInput (options, callback) { | |
allUserData.push (options); | |
callback (options); | |
} | |
// When we call the getInput function, we pass logStuff as a parameter. | |
// So logStuff will be the function that will called back (or executed) inside the getInput function | |
getInput ({name:"Rich", speciality:"JavaScript"}, logStuff); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment