Skip to content

Instantly share code, notes, and snippets.

@cld-santos
Created October 25, 2013 00:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cld-santos/7147790 to your computer and use it in GitHub Desktop.
Save cld-santos/7147790 to your computer and use it in GitHub Desktop.
This sample shows how to iteratate through a multidimensional array avoiding the closure issue.
console.clear();
function printRecursiveArray(value, c){
for(c=0; c<value.length; c++){
if (typeof value[c] !=='object'){
console.log(value[c]);
}else{
printRecursiveArray(value[c],0);
}
}
}
var vector = [1,[1,2,3],2,3];
printRecursiveArray(vector,0);
console.log('vector[1][2]:' + vector[1][2]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment