Created
September 4, 2022 18:31
-
-
Save sabesansathananthan/54f62d3a6cd6469096dae50ba636d51f to your computer and use it in GitHub Desktop.
How to override methods in localStorage?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { setItem } = localStorage.__proto__; | |
localStorage.setItem = function (key, value) { | |
console.log('localStorage.__proto__.setItem', key, value); | |
setItem.call(this, key, value); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment