The plus ( + ) operator and String.concat() method gives the same result.
plus ( + ) operator;
str1 + str2;
String concat() method;
str1.concat(str2);
Addionally, it is written in w3schools ;
But with JavaScript, methods and properties are also available to
primitive values, …
What's the "best" way to convert a number to a string (in terms of speed advantage, clarity advantage, memory advantage, etc) ?
Some examples:
String(n)
n.toString()
""+n
n+""
I'm writing a Chrome extension that involves doing a lot of the following job: sanitizing strings that might contain HTML tags, by converting <, > and & to <, > and &, respectively.
(In other words, the …