Skip to content

Instantly share code, notes, and snippets.

@kuznetsovandrey76
Created January 26, 2017 16:57
Show Gist options
  • Save kuznetsovandrey76/b10dc4ad256073ee01ecc00b5bed3ab6 to your computer and use it in GitHub Desktop.
Save kuznetsovandrey76/b10dc4ad256073ee01ecc00b5bed3ab6 to your computer and use it in GitHub Desktop.
var arr = [
[1,2],
[3,4],
[5,6]
];
var temp = [];
for (var i = 0; i < arr.length; i++) {
temp.push(arr[i][0], arr[i][1]);
}
function foo(index, timeout) {
setTimeout(function(){
console.log(temp[index])
}, timeout);
}
for (var i = 0; i < temp.length; i++) {
// Вызываем функцию столько раз сколько элементов
foo(i, i * 1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment