How to check if duplicate key exists in local -storage in ionic


#1

I have stored data in local storage,with key and values,

key is account name…
When a user creates a new account ,i want to put a check if the same key exists or not …

how should i achieve this,if the same key exists,then alert should be created else not…

I tried using the get item function ,but everytime it returns null,wheteer or not the key exists…

 if(localstorage.getItem(this.account.value.name)===null)
{
alert
}
else..
{
}

this does not works for me…


#2

Duplicate at How to check if key exists in local-storage


#3