JavaScript Tutorial





Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
Java-Script Tutorial
Introduction Introduction
Variables Variables
Operators Operators
Statements Statements
Loops Loops
Functions Functions
Objects Objects
Arrays Arrays
Cookies JS Cookies
Browser Objects Browser Objects
Form DOM Form DOM
Style Objects DOM Style Objects
Forums Ask Your Doubts
Scraps More about Javascript
Feedback Feedback
 




String Function - split()


Tutorials Javascript

Topic

how to split or concatenate a string in javascript?



Explanation

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("-");
document.write(result);
</script>

Result:

Explanation:
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.





  • A Note
    Javascript (JS) is one of the most used languages in the world. Some times spelled as Java Script. Hope you enjoy this tutorial. Do send your feedback or suggestions on this javascript or java script tutorial. This is a copyright content.

    Other Links

    web hosting