-
-
Save malintha/262ea1e1a1c60f371ef593a0ba5c2f39 to your computer and use it in GitHub Desktop.
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
firstFunctionCall : find([1,2], function(elements) { | |
alert("Results : "+elements); | |
}); | |
alert("meanwhile I show up"); | |
function find(elements, callback) { | |
//The time consuming operation | |
setTimeout(function() { | |
elements.push(3,4,5); | |
if(typeof callback === "function") { | |
callback(elements); | |
} | |
else { | |
alert("Retrieved function is not a callback"); | |
} | |
} ,2000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment