Assume I have an object as;
test = Object
3232@alex= Object
5656@alex= Object
8383@felix= Object
98232@tom= Object
I want to get the objects in test where the key value contains alex, I mean the first two objects.
3232@alex= Object
5656@alex= Object
Normally I reach them as test["3232@alex"]
or test."3232@alex".
Now can I write a regex expression to get the objects where key contains "alex
" for example.I know I can loop through the object as;
var arr = [];
for(var key in test){
if(key.contains("alex")){
arr.push(test[key]);
}
}
Is it the only way to do it? I'm actually looking for a solution which avoids loop.