Javascript - split ()

October 2016

Strings play a very important role in programming and should be handled carefully to avoid getting any errors. Many programming languages like Strings have built in functions that help the user to modify a piece of string as per the requirements of the code. Strings has a built in split function which allows the user to subset a piece of string. Using the split function, one can extract multiple portions separately from a single piece of string.

The split () function allows you to split a string and return the results in a table, using a string defined as a separator.

In the example below, the split () can cut the date according to the character '/':

var date = '26/02/2009';  
var elem = uneDate.split('/');  
day = elem[0];  
month = elem[1];  
year = elem[2];

Related :

This document entitled « Javascript - split () » from CCM ( is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.