Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for (var i = 1; i <= 10; i++) {
- setTimeout(function(j) {
- console.log(j);
- }(i), 1000);
- }
- for (var i = 1; i <= 10; i++) {
- setTimeout(function(j) {
- return function() {
- console.log(j);
- }
- }(i), 1000 * i); // Delay
- }
- var i = 0;
- function start() {
- setTimeout(function() {
- i++;
- console.log(i);
- // If we haven't reached our limit, start again
- if(i < 10) start();
- }, 1000);
- }
- start();
- for (var i = 1; i <= 10; i++) {
- setTimeout(function(j) {
- console.log(j);
- }(i), 1000 * i);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement