Skip to content

Instantly share code, notes, and snippets.

@arindam89
Last active August 29, 2015 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arindam89/7c27bbedabaca08337c5 to your computer and use it in GitHub Desktop.
Save arindam89/7c27bbedabaca08337c5 to your computer and use it in GitHub Desktop.
JS Demos for Loupe
function process(num) {
// delay();
console.log(num);
}
// Synchronus
[1,2,3,4].forEach(function(i){
process(i);
});
// Asynchronous
function asyncForEach(array, process) {
array.forEach(function(i){
var j = i;
setTimeout(function(){
process(j);
},0);
});
}
asyncForEach([1,2,3,4],process);
$.on('button', 'click', function onClick() {
setTimeout(function timer() {
console.log('You clicked the button!');
}, 2000);
});
console.log("Hi!");
setTimeout(function timeout() {
console.log("Click the button!");
}, 5000);
console.log("Welcome to loupe.");
setTimeout(function Timeout(){
console.log('one second!');
}, 1000);
setTimeout(function Timeout(){
console.log('one second!');
}, 1000);
setTimeout(function Timeout(){
console.log('one second!');
}, 1000);
setTimeout(function Timeout(){
console.log('one second!');
}, 1000);
// Show how events work.
function animating(){
delay();
}
$.on('document','scroll',animating);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment