How to use Split in JavaScript

In this article we will discuss about how to use Split() Method in JavaScript.
  • 2380

The Split method works with the strings in JavaScript. This method split an String object into substring separated by the comma. Split method work as a separator to divide a string into substring. Here is the syntax to define it.


string.split ([seperator] [, limit]);

In this separator specifies which character will be use to separate the string in to substring and limit specifies the integer number which further specifies the number of splits to be displayed or found.

Lets have a look on the following example:



<title>JavaScript String split() Method</title>



<script type="text/javascript">


    var str = "Earth is round, and Moon is round.";


    var splitted = str.split(" ", 5);









Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here


More Articles

© 2020 DotNetHeaven. All rights reserved.