Open brettz9 opened 6 years ago
NaN
is a primitive; i think Number.isNaN
is sufficient to detect that. arguments
already has a ToStringTag, so there's no reason it wouldn't be able to report "Arguments" here.
yes, just like ToStringTag (which was primarily added for HTML elements, as I understand it), this would allow engines to do the same.
Ah yes, re: arguments
, thank you.
While NaN
can be detected by Number.isNaN
, it seems unnecessarily cumbersome (and making for less immediately readable code) to need to add a special type-checking case for it; moreover, I'd expect most uses of type-based switch statements would not be seeking to treat NaN
the same as number
(and if they were, they could easily add another fall-through case
to handle both together).
the type of NaN
is number; it wouldn't be appropriate for something called "typeOf" to return anything other than "number" for it.
The typeof
of null
is, and with this proposal, remains, "object" as well. There can be different types of types. :-)
And looking at it semantically, "not a number" is not a number. :-)
NaN represents “no number”, just like null represents “no object” ¯\_(ツ)_/¯
Despite the spec naming it "Not-a-Number", I think that is a fair characterization. However, again, the proposal currently (and thankfully) distinguishes null
from "object".
Indeed; this is more akin to Object.prototype.toString.call(null).slice(8, -1)
:-)
A few different observations or suggestions regarding the
typeOf
examples:new WebAssembly.Module()
would I guess give the same as the Module exotic object:... so maybe the above should be indicated as such (if not differentiated)?
NaN
andarguments
are interesting enough to describe their expected valuesHTMLSelectElement
), and if so, maybe raising an example possibility would even better demonstrate the potential.