I was writing to see if I can manipulate jquery arrays.
So I have an object:
myobject = {
abc : {
value : 'abc',
template : '<div class="abc"></div>',
},
},
Now what I have is another array that looks like this:
myarray = ["abc", "cde"];
So what I am trying to do is loop through myarray
to see if it matches an object in the myobject
.
Now I thought you would accomplish this by doing something like this:
for (var i = 0; i < myarray.length; i++) {
if (myobject.myarray[i]) {
// do something
}
}
Now this gives me an error: Uncaught TypeError: Cannot read property '0' of undefined
So clearly this isn't the approach, how can I loop through myarray
to see if myobject
has an object that matches the name from the myarray
array?