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 o = { | |
note: 'default note' | |
}; | |
Object.defineProperty(o, 'letter', { | |
get: async function () { | |
return this.note; | |
}, | |
set: async function (value) { | |
await new Promise((resolve) => { |
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 summ = function (...args) { | |
let arity = 0; | |
let storage = []; | |
const isNumber = (el) => { | |
return (this instanceof Number) || typeof el === 'number' && !Number.isNaN(el); | |
}; | |
if (isNumber(this)) { | |
arity = 0 + this; |
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 ArityWithCallback = function (callback) { | |
// callback length is number of arguments | |
// that callback can accept before | |
// it has to be called | |
const arity = callback.length; | |
const storage = Array.isArray(this) ? this : []; | |
if (arity === 0) { | |
return callback; |
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 DerivedPrimitiveFactory = function (existentInstance, ModificatorType) { | |
const TripleSchemeClosure = function () { | |
ModificatorType.prototype = this; | |
ModificatorType.prototype.constructor = ModificatorType; | |
return ModificatorType; | |
}; |
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
// explorable Document Flow Definition | |
const NUMBER_2_EXPLORE_FROM = new Number(5); | |
const someData4DFD = [5, 4, 3, 2, 1]; | |
const ExplorableDFD = function (explorable) { | |
const proto = Object.getPrototypeOf(this); | |
const protoValue = proto.valueOf(); | |
debugger; |
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 MyNull = function () {}; | |
MyNull.prototype = null; | |
const s = new MyNull(); | |
// as this might be only the object, | |
// so null would be converted | |
console.log(s); | |
console.log(s.valueOf()); // {} |
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
class MyClass {} | |
class FunctionAsInstance extends MyClass { | |
constructor(...args) { | |
super(); | |
const me = this; | |
this.args = 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
'use strict'; | |
const vectorObj = new Number(5); | |
const proxyAsNumber = new Proxy(vectorObj, { | |
get (target, prop) { | |
if (prop === Symbol.toPrimitive) { | |
return function (...args) { | |
// this -- proxy itself | |
// args === ['default'] |
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()); |
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
// there is Object [null prototype] | |
// under the hood, so we have room there | |
var a = new Number(5); | |
a.extract = function () { | |
return a.valueOf(); | |
}; |