I have an object acting like Hash table.
var ob = {
"Earnings": {
"name": "Finance",
"id": "0"
},
"Total": {
"token_id": 90,
"Token": {
"name": "E32"
}
}
}
Now the point is that I have value not key of ob.
I have value :
{
"token_id": 90,
"Token": {
"name": "E32"
}
}
}
I need to find whether the value exists in ob efficiently. I had tried the loop approach like this.
for (var key in ob) {
if (ob.HasOwnProperty(key)) {
//check for the value
}
}
This approach is fine for small data but for large data its taking time. So, Is there any way I can solve this use case by getting(searching) in O(1) time?