Can anybody please explain this:
> d = new Date()
2022-06-22T03:27:24.357Z
> d2 = Object.assign({ __proto__ : d.__proto__ }, d)
Date {}
> d2 instanceof Date
true
> d2.toString()
Uncaught:
TypeError: Method Date.prototype.toString called on incompatible receiver [object Object]
at Date.toString (<anonymous>)
The same occurs if using Object.create instead of Object.assign. Also it occurs with Node.js Buffer as well.
I'm trying to understand how type checking is performed here, since instance of Date is object and has the same prototype.