Last active
August 29, 2015 14:18
-
-
Save arindam89/7c27bbedabaca08337c5 to your computer and use it in GitHub Desktop.
JS Demos for Loupe
This file contains hidden or 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
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); |
This file contains hidden or 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
$.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."); |
This file contains hidden or 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
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); |
This file contains hidden or 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
// 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