String Function - split()

how to split or concatenate a string in javascript?


Object: String
Method or Function: split(string)
Description: It takes one argument called as delimiter. The argument is used to split the string in to an array of string. Every part that comes in between the delimiter is separated as a string. A delimiter can be any string or a character or even blank space.

Example Code:
<script language=javascript>
var ss = "testing-delimiter-split-function";
var result = ss.split("-");


In the above example,
  • the main string is stored in a variable ss.
  • the method split takes the one argument, here it is "-".
  • the delimiter character "-" is used to split or concatenate the string.
  • any thing that comes in between the delimiter ("-") is separated in to a new string.
  • the result variable is an array of string.

Ask Questions

Ask Question