Javascript Split Method

JavaScript has a split method to divide up a string. The split method takes a string and converts it to an array, cut-up based upon a given string of one or more characters.

The example below will split the querystring of a website URL into its individual parameters

var parameters = new Array();
parameters = queryString.split('&');

There is an optional parameter to limit the number of entries returned, however I’ve not found a need to use it. The above example amended with the limit option to only get 4 parameters becomes:

var parameters = new Array();
parameters = queryString.split('&', 3);

To show the individual parameters in the array from the split function
document.write( parameters );