How To Use String Object Split In JavaScript

In this article I am going to explain about String Object Split In JavaScript.
  • 1625

Use split() method in JavaScript

This method is used to split a string value and return the new string array.

If the string is empty, the the split returns an array containing one empty string, rather than an empty array.

The split() method does not change the original string in JavaScript.

All browsers support string object split() method.




<!DOCTYPE html>


<body style ="background-color:red">


<p id="demo">Display the array values after the split.</p>


<button onclick="myFunction()">Click here</button>


<script type="text/javascript">

    function myFunction()


        var str = "Welcome to tne dotnetheaven?";

        var n = str.split(" ");

        document.getElementById("demo").innerHTML = n;










Further Readings

You may also want to read these related articles :here

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.