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

前端 未结 1 1857
醉酒成梦
醉酒成梦 2020-12-10 00:07

I\'m using localStorage in a Chrome extension.

Is there any difference between delete localStorage[key] and window.localStorage.remov

相关标签:
1条回答
  • 2020-12-10 00:46

    There's no difference in Chrome, but i recommend using localStorage.removeItem(key) so that you get in the habit of doing so. That way, when you go to use localStorage in a website, you are already using the method that is most likely to work with shims and polyfills for outdated browsers.

    0 讨论(0)
提交回复
热议问题