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

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

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

This solution works in most browsers, but not in IE8:

Storage.prototype.setObject = function(key, value) {
    this[key] = JSON.stringify(value);
}

Storage.prototype.getObject = function(key) {
    return JSON.parse(this[key]);
}

After some research, I, apparently, could use Lawnchair.js or work on it in some other way. But I wonder why this does not work in IE8. I can extend String and Array. Why not store? How can I find out which objects I can expand, and which of them I can not expand in IE8?

+3
source share
1 answer

IE. DOM. , Storage.prototype.getObject.call(localStorage, 'hello').

.

+2

All Articles