Created
September 7, 2020 09:23
-
-
Save wentout/8f17ae2c9280cdf577f2f1a5ae175467 to your computer and use it in GitHub Desktop.
// Number -> Proxy Life Cycle
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
| // Number -> Proxy Life Cycle | |
| const ogp = Object.getPrototypeOf; | |
| var a = new Number(5); | |
| a.extract = function () { | |
| return a.valueOf(); | |
| }; | |
| console.log(a.extract()); | |
| var b = new Proxy(a, {}); | |
| console.log(b.extract()); | |
| var c = new Number(7); | |
| c.extract = function () { | |
| return c.valueOf(); | |
| }; | |
| Object.setPrototypeOf(Object.getPrototypeOf(c), b); | |
| console.log('c.valueOf()', c.valueOf()); | |
| console.log('c.extract()', c.extract()); | |
| console.log('ogp(c).extract()', ogp(c).extract()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment