I need to do a lot of searches parsing xmlStream if I need some kind of tag or not.
I can do this using the array.indexOf method (I have about ~ 15 elements in the array) or by searching for the [key] object.
The second solution seems to be more effective in theory for me, but does not look beautiful in my code. But if it is really more effective, I would leave it as it is.
eg:.
var tags = [
'tag1',
'tag2',
'tag3',
...
];
var tags2 = {
'tag1' : null,
'tag2' : null,
'tag3' : null,
}
tags.indexOf(value)
tags2[value]
source
share