Hi Nicholas,
I love reading your books. i have one question regarding Symbol.hasInstance overriding mechanism you mentioned.
Page #134
-------------------------------------------------------------------
function MyObject() {
}
Object.defineProperty(MyObject, Symbol.hasInstance, {
value : () => 0 // anything returned here is converted to boolean
})
let obj = new MyObject();
obj instanceof MyObject // false
------------------------------------------------------------------
My question: although we are able to hack the hasInstance method, yet Symbols are still hiding internal logics where that Boolean step is performed, could you explain or write something about that, without that piece we are still in dark what could happen inside "magic" part of javascript.
I really enjoyed learning Symbols in JS but this small piece is stuck in my head and wanted to understand how it works under the hood.
Thanks.
Nutan Gwari