Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between removeItem and delete [duplicate]

Possible Duplicate:
Deleting from localStorage: should I use delete or .removeItem?

What is the difference between

localStorage.removeItem("my_variable_in_storage")

And

delete(localStorage.my_variable_in_storage)

Besides that first returns "undefined" and second true boolean.

like image 722
Paul Brewczynski Avatar asked Nov 03 '22 07:11

Paul Brewczynski


1 Answers

You should use localStorage.removeItem(). While delete may work, it's not part of the spec and it may just be a lucky coincidence that it's working for you right now.

like image 85
hunterloftis Avatar answered Nov 08 '22 04:11

hunterloftis