I want to access an element in an array in javascript without having to do a for loop to access it.
Here's my array:
var array = [{
"title": "Warnings",
"numbers": 30,
"content": [{
"number": 3001,
"description": "There may be a problem with the device you are using if you use the default profile"
}]
}, {
"title": "Errors",
"numbers": 20,
"content": [{
"number": 1000,
"description": "No network is loaded"
}]
}]
I want to access the "content" attribute of "Warnings" without doing a for loop.What I'm currently doing to access it is the following:
var content;
for(a in array) {
if(a.title == "Warnings") {
content = a.content;
break;
}
}
Is that something feasible in javascript ?