Last active
December 29, 2015 01:39
-
-
Save alanerzhao/7594407 to your computer and use it in GitHub Desktop.
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
//array chunking | |
function chunk (array,process,context) { | |
setTimeout(function () { | |
//取出数组每一项 | |
var item = array.shift(); | |
//处理函数 | |
process.call(context,item); | |
//只要不为空 | |
if(array.length > 0) { | |
setTimeout(arguments.callee,100); | |
} | |
},100) | |
} | |
var data = [1,2,3,4,12,12,12,312,312,3123,12,312,2,2,4,5,65,56,67,87,89,98,90,09,890,78,56,34,432,324]; | |
function printValue(item) { | |
var div = document.getElementById("myDiv"); | |
div.innerHTML += item + "<br>"; | |
console.log(item); | |
console.log(data); | |
} | |
chunk(data.concat(),printValue); | |
//假死 | |
var data = []; | |
for(var i = 0; i < 100000; i ++) { | |
data[i] = i; | |
printValue(data[i]) | |
} | |
function printValue(item) { | |
var div = document.getElementById("myDiv"); | |
div.innerHTML += item + "<br>"; | |
console.log(item); | |
} | |
printValue(data[i]) | |
console.log(data); | |
// chunk(data.concat(),printValue); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment