In this tutorial, We will learn how to split a string into an array by comma using jquery.


Example

<!DOCTYPE html>
<html>
    <head>
        <title>How to split string to an array</title>
    </head>
    <body>
        <script type="text/javascript">
            var myString = "A,B,C,C,D,E,F,G,H";
            console.log(myString.split(','));
        </script>
    </body>
</html>


output:

[
    "A",
    "B",
    "C",
    "C",
    "D",
    "E",
    "F",
    "G",
    "H"
]

Thanks, May this example will help you......