concat vs join

+1 Faisal Hamidi · December 30, 2014
can we use join instead of concat if we can than what is the difference?
thank you

Post a Reply

Replies

Oldest  Newest  Rating
0 Jay Deshaun · December 30, 2014
That's exactly the difference between those 2.
0 Faisal Hamidi · December 31, 2014
thank u guys :)
0 Sochima Biereagu · January 10, 2015
.join() converts an array into a string and seperates it with the argument you pass.

var arr = new Array("hello", "world");
arr.join("+"); //=> "hello+world"

while the .concat() method concatentaes an array, joins the argument(s) you pass in to the array

var arr = new Array("hello");
ar.concat("world"); //=>["hello","world"]
  • 1

Javascript

127,950 followers
About

A scripting language that is added to standard HTML to create interactive effects, apps, games for the browser.

Links
Moderators