Reputation: 169451
({}).toString.call(Number.prototype) === "[object Number]"
The Number prototype object is itself a Number object (its [[Class]] is "Number") whose value is +0.
Why would it be useful for Number.prototype
to be a Number? (the same goes for every other built-in prototype which has the [[Class]] set to not Object)
I'm picking on Number.prototype
specifically because I can imagine sensible legacy reasons for Array.prototype
and Date.prototype
.
Upvotes: 16
Views: 411
Reputation: 112857
In general, Constructor.prototype
is an exemplar of the "type" defined by Constructor
. Although things seem to get hairy for immutable primitives, and especially once you involve the boxing stuff, this exemplar concept still makes sense, with 0
being the "exemplar" of Number
.
Upvotes: 1
Reputation: 147453
The Number prototype object is itself a Number object (its [[Class]] is "Number") whose value is +0
Why wouldn't Number.prototype
be a Number object? Its [[Prototype]]
is Object.prototype, so it still inherits from Object.
Upvotes: 1