Wednesday, 1 April 2015

How to use concat in Javascript?. how to work this?

The concat() method can be used instead of the plus operator. These two lines do the same:

var text1 = "Hello";
var text2 = "World";
text3 = text1.concat(" ",text2);
alert(text3);

var text = "Hello" + " " + "World!";
var text = "Hello".concat(" ","World!");
alert(text);

No comments:

Post a Comment