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.
I would like to know if there are any differences between them:

value.toString()
String(value)
value + ""

DEMO

They all produce the same output, but does one of them better than the others?
I would say the + "" has an advantage that it saves some characters, but that’s not that big advantage, anything else?

8 Answers
8

Leave a Reply

Your email address will not be published. Required fields are marked *