Created
October 25, 2013 00:54
-
-
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.
This file contains 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
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