Join Nostr
2025-10-01 20:30:10 UTC

Zach Leatherman on Nostr: is there really no low-level mechanism to intercept boolean primitive coercion in ...

is there really no low-level mechanism to intercept boolean primitive coercion in JavaScript?

why can’t I extend `Boolean` to make `new MyBoolean(false)` be `falsy`? (I understand why it isn’t, but I want to make it so)

> Note: Unlike other type conversions like string coercion or number coercion, boolean coercion does not attempt to convert objects to primitives by calling user methods.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean#boolean_coercion