Why can't I extend localStorage on IE8 (javascript)?

前端 未结 1 1703
一个人的身影
一个人的身影 2021-01-20 15:48

I\'d like to add 2 methods to localStorage. My goal is to end up with something like this:

localStorage.setObject(key, object);
localStorage.getObject(key);         


        
相关标签:
1条回答
  • 2021-01-20 16:12

    This is IE. You also can't extend DOM elements. If you sometimes really-really need to call a function, you can do it via Storage.prototype.getObject.call(localStorage, 'hello').

    Also extending built-in objects is not considered as good thing.

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