Reputation: 1559
I am trying to read a localstorage where key itself is an object. I understand it's a string but still look like an object. Something like this.
{
"key1":"value1",
"key2":"value2",
"key3":"value3",
"key4":"vaule4"
}
The issue is that I know the value of all the keys and few values but not all values. I am not sure how to use localstorage apis to read this object. I am looking for something similar to contains where I can check if key contains this subkey.
Upvotes: 0
Views: 62
Reputation: 30360
To detect if an object has a key, you can call .hasOwnProperty(key_name)
on the object instance which will return either true or false
Upvotes: 1