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 Forkable = function () { }; | |
| Object.defineProperty(Forkable.prototype, 'fork', { | |
| get () { | |
| const me = this; | |
| return function (...args) { | |
| debugger; | |
| // this keyword points to instance itself | |
| if (new.target) { | |
| return new me.constructor(...args); |
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 ogp = Object.getPrototypeOf; | |
| const osp = Object.setPrototypeOf; | |
| const supervise = (instance, args) => { | |
| const seek4name = args.callee.name; | |
| let current = instance; | |
| do { | |
| if (current === null) { | |
| break; | |
| } |
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
| 'use strict'; | |
| function anotherBeBound () { | |
| debugger; | |
| this.b = this.a; | |
| if (!new.target) { | |
| return this; | |
| } | |
| }; | |
| anotherBeBound.prototype.a = 2; |
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
| 'use strict'; | |
| let toBeProp = 5; | |
| const myObject = {}; | |
| Object.defineProperty(myObject, 'prop', { | |
| get () { | |
| return { | |
| [Symbol.toPrimitive] () { | |
| return toBeProp; |
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
| 'use strict'; | |
| const frozen = (() => { | |
| return { | |
| get propName () { | |
| return 123; | |
| } | |
| }; | |
| })(); |
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
| 'use strict'; | |
| const GenerateError = function (error) { | |
| if (!(error instanceof Error)) { | |
| error = new Error('defaults'); | |
| } | |
| debugger; | |
| Object.setPrototypeOf( |
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
| 'use strict'; | |
| const MAX_NUM = 1000; | |
| global.m = []; | |
| global.start = Date.now(); | |
| global.current = { | |
| name: 'root' |
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
| 'use strict'; | |
| const ogp = Object.getPrototypeOf; | |
| const myNumber = new Number(5); | |
| const arr = new Array(1, 2, 3); | |
| const example = {}; | |
| console.log(ogp(arr)); // Object(0) [] | |
| console.log(ogp(ogp(arr))); // [Object: null prototype] {} |
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 a = new Number(100); | |
| a.subtract = function (b) { | |
| return this.valueOf() - b; | |
| }; | |
| console.log(a.subtract(10)); // 90 | |
| console.log(a - 10); // 90 | |
| console.log(a - 10); // 90 | |
| console.log(a - 10); // guess |
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
| 'use strict'; | |
| const myArrow = () => {}; | |
| const myFn = function () {}; | |
| class MyClass {}; | |
| const isArrowFunction = (fn) => { | |
| if (typeof fn !== 'function') { | |
| return false; |