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. Syntax:
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:
<html>
<head>
<title>JavaScript String split() Method</title>
</head>
<body>
<script type="text/javascript">
var str = "Earth is round, and Moon is round.";
var splitted = str.split(" ", 5);
document.write(splitted);
</script>
</body>
</html>
Output:
Ask Your Question
Got a programming related question? You may want to post your question here Programming Answers here