Saturday, July 4, 2015

.concat in JavaScript is for concatenation

var yin = "Hello";
var yang = "World";
var yinyang = yin.concat(yang);
console.log(yinyang);

 
 

Gives us HelloWorld while the following gives us an array of two strings wherein the first string is Hello and the second string in World.

var yin = new Array("Hello");
var yang = new Array("World");
var yinyang = yin.concat(yang);
console.log(yinyang);

No comments:

Post a Comment