Replying to
@rebane2001@infosec.exchange oh wow, that was harder than I thought.
Final answer: const x = (BigInt.prototype.length = 1, 0n)
What I tried:
Realize you need a value that's falsy but has a truthy length.Try to use an object with [Symbol.toPrimitive] custom implementation. Failed because objects are directly truthy and not converted to bool.Try to override String.prototype.length and use an empty string. Failed because init x as an empty string seems to set the length again.Had to look up falsy JS values and saw BigInt. Good because 0n is falsy, and BigInt doesn't use length so we can set it without it getting reset.
Phew, it was a lot harder than I thought at first. But then, if you know the solution it's not that hard to understand.