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

后端 未结 4 2074
北荒
北荒 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:10

    You are almost right. There is something called autoboxing (wrapping primitives in objects) http://princepthomas.blogspot.com/2011/07/auto-boxing-javascript-primitive-types.html


    edit: sory for duplication of Mike Christensen link - I did not notice it.

提交回复
热议问题