Why are methods of String.prototype available to string literals?

后端 未结 4 2091
北荒
北荒 2020-12-19 10:30

This question has come out of another, which concerns the behaviour of console.dir with string literals. In particular, see the comments on my answer.

A

4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-19 11:09

    That's exactly what it's doing.

    Javascript boxes primitive types as needed.

    Here's some more information:

    http://princepthomas.blogspot.com/2011/07/auto-boxing-javascript-primitive-types.html

提交回复
热议问题