Given that a literal number not strictly an instance of Number
, why can I call prototype methods of Number
(or String
, or Boolean
) objects on the corresponding literal objects? Is this standard behavior across browsers?
What exactly is happening when this occurs? I suspect it's coercing the literal into the corresponding type before calling the method, because when I inspect typeof this
in the method, it's returning 'object'
rather than 'number'
.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…