Casting to string in JavaScript

前端 未结 8 1716
轻奢々
轻奢々 2020-12-04 07:59

I found three ways to cast a variable to String in JavaScript.
I searched for those three options in the jQuery source code, and they are all in use

8条回答
  •  無奈伤痛
    2020-12-04 08:49

    On this page you can test the performance of each method yourself :)

    http://jsperf.com/cast-to-string/2

    here, on all machines and browsers, ' "" + str ' is the fastest one, (String)str is the slowest

提交回复
热议问题