today i learned BigInt(string)
first converts the string into the number
type and then just invokes BigInt(number)
so that’s lossy, right,
@Lady i really did simply misread the spec
@aescling in fairness it’s an easy mistake but yeah the second argument to ToPrimitive is just a hint and not a guarantee of the actual return type
@aescling what no it doesn’t
(spec text follows)
When BigInt is called with argument value, the following steps are taken:
1. If NewTarget is not undefined, throw a TypeError exception.
2. Let prim be ? ToPrimitive(value, `number`).
3. If Type(prim) is Number, return ? NumberToBigInt(prim).
4. Otherwise, return ? ToBigInt(value).
(end spec text)
ToPrimitive(string, `number`) === string since strings are already primitives; that step does nothing