I have an Array in the following format :
[["tag1","tag2","tag3","tag4","tag5","tag6","tag7","Thy","YUI"],["","",0,"jkghjg","hgjhg","kjhkjhg","kjghjkg)","gjhg","jkjkghj"]]
I need to "foreach" the array and get each values one by one like: Features , notes ...
When I put it into $.each()
I am getting this error:
Uncaught TypeError: Cannot use 'in' operator to search for '1103' in ..
How do I get it?
try this
var a = [["Features", "Notes", "Code", "Value", "Testing", "BAC", "Total", "Thy", "YUI"], ["", "", 0, "jkghjg", "hgjhg", "kjhkjhg", "kjghjkg)", "gjhg", "jkjkghj"]]
$.each(a, function (i, data) {
$.each(data, function (j, val) {
console.log(val);
});
});
you can also try this if you want to use foreach method
Array.prototype.forEach.call(a,function(rm){
rm.map(function(ed){
console.log(ed)
})
})
did you mean make the array as associative JSON object? try this
var a = [["Features", "Notes", "Code", "Value", "Testing", "BAC", "Total", "Thy", "YUI"],
["", "", 0, "jkghjg", "hgjhg", "kjhkjhg", "kjghjkg)", "gjhg", "jkjkghj"]]
var json = {}
for (var i in a[0]) {
var key = a[0][i];
var val = a[1][i];
json[key] = val;
}
console.log(json);
console.log(json.Testing);
</div>
var a_data= [["Features","Notes","Code","Value","Testing","BAC","Total","Thy","YUI"],["","",0,"jkghjg","hgjhg","kjhkjhg","kjghjkg)","gjhg","jkjkghj"]]
var output="";
$.each(a_data,function(index,data){
output+=data.join(",")
})
console.log(output)