JQuery Array to string with join

From CoderLearner
Jump to: navigation, search

jQuery Create String From Array

Uses join() function to join array elements into string.

Syntax $.join()

  • myFruits is the array to be joined
  • join_ch is the character or string uses to join the array's elements
 
myFruits.join(join_ch);

Example

$(document).ready(function() {
	var myList =[1,5,6,23,53];		
        myList = myList.join('-');
        alert(myList);
});

Output

1-5-6-23-53