2 ms·
A small fix: if ( v.constructor === T) { return x; } should really better be: if ( v !== null && v !== undefined && v.constructor === T) { return x
by galaxyLogic 4y ago
A small fix:
if ( v.constructor === T)
{ return x;
}
should really better be:
if ( v !== null && v !== undefined && v.constructor === T)
{ return x;
}
The purposes of x() is to throw an error under specific circumstances, and the original version does that. But when we do v.constructor if v is undefined or null and 'maybe;' is falsy then it throws an error but the message is obscure since it is caused by trying to get the constructor of undefined or null.