Created
October 23, 2013 18:21
-
-
Save acatl/7123843 to your computer and use it in GitHub Desktop.
loop break
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
var la = new Array(500); | |
for (var i = 0; i < la.length; i++) { | |
la[i] = i; | |
} | |
var target = []; | |
var loop = function () { | |
var temp = la; | |
var slices = 50; | |
var timer = setInterval(function () { | |
var len=temp.length | |
for (var i=0;i < len;i++) { | |
if (i==slices) { | |
console.log("exit loop"); | |
break; | |
} | |
target.push(temp[i]); | |
console.log(i); | |
} | |
temp = temp.slice(slices, -1); | |
if(temp.length==0){ | |
console.log("exit timer", target, '-------', la); | |
clearInterval(timer); | |
} | |
},0); | |
} | |
loop(); | |
console.log('outsite', la.length); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment