In Why is BigInt() broken? I noticed this comment by @ljharb:
We’ve tried pretty hard to avoid that legacy pattern, and make absence and undefined always be treated the same.
I can't help but wonder if this doesn't introduce a potential issue.
If Foo()
is identical to Foo(undefined)
, then that seems to imply that Foo(undefined, undefined)
is also the same as Foo()
, as would any length of undefined parameters. Even if this seeming implication is false, the original statement seems to contradict the behavior of arguments in general.
function Foo(...args) {
console.log(`argument count: ${args.length}`);
}
In the end, such a convention seems to be just as awkward as property presence detection done as such:
let a = { bar: undefined; }
if (a.bar === undefined) {
...
}
Please do not argue on the poor nature of such a test. Any such argument is moot as, sadly, code with similar construction exists in the wild.
In both cases, the detectable presence of a value is being ignored. I'm not arguing that the legacy pattern should be continued. I would simply like to have an understanding of the desire to change the well-known, and occasionally useful pattern.