I have tried the following code snippet:
var arrVal = [[1,2],[[2,3],[4,5]],3,4];
var async = require('async');
var recurse = function(arr , callback) {
async.eachSeries(arr, function(eachVal, callback) {
if(typeof eachVal == "object") {
recurse(eachVal);
}
else {
console.log(eachVal);
callback(null);
}
}, callback);};
recurse(arrVal);
Expected to print all the numbers present in arrVal array, but I am getting only 1,2 (Numbers of 0th index of the array).
What I am doing wrong? Can someone guide with the better way to achieve what I want to get?
NOTE: I was hoping to do this asynchronously