How to split string to array by Comma using jquery?

Today, We want to share with you jquery split string to array.In this post we will show you jquery string to array, hear for implode in jquery & jquery explode string we will give you demo and example for implement. In this post, we will learn about Demo with an example.

JavaScript String split() Method

The split() function is used to split a string into array of substrings, and returns the new array.

Are you need to explode string to array by comma in jquery, then We will give you best step by step solutions to explode string to array by comma, space etc. we will do it using jquery split(). we will split string into array by space or comma in jquery.

We created simple string with comma. then i will use split function to create an array using split function in jquery.

Read Also:  javascript split string by comma

How to Convert Comma Separated String into an Array in JavaScript

so let’s see bellow simple example:
Use the split() Method

<!DOCTYPE html>
<html>
<head>
    <title>How to split string to array by comma using jquery? - www.pakainfo.com</title>
</head>
<body>

<script type="text/javascript">

    var product_title_tags = "A,B,C,C,D,E,F,G,H";

    console.log(product_title_tags.split(','));    

</script>
</body>
</html>

jquery explode string

You can use the JavaScript split() special method to split a string using a specific each separator such as comma (,), space, etc.

Read Also:  jquery remove last comma from Array Example

Example 2: index.html

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Convert Comma Separated String to Array in JavaScript - www.pakainfo.com</title>
</head>
<body>
    <script>
    var movies = 'Tamilrokers,khatrimaza,Bolly4u,mp3goo,english,infinityknow';
    var product_title_tags = movies.split(',');
    console.log(product_title_tags);
     
    // Accessing individual values
    document.write(product_title_tags[0] + "<br>"); // Prints: Tamilrokers
    document.write(product_title_tags[1] + "<br>"); // Prints: khatrimaza
    document.write(product_title_tags[product_title_tags.length - 1] + "<br>"); // Prints: infinityknow
     
    var str = 'Welcome To Pakainfo!';
    var items = str.split('');
    console.log();
     
    // Accessing individual values
    document.write(items[0] + "<br>"); 
    document.write(items[1] + "<br>"); 
    document.write(items[items.length - 1]); 
    </script>
</body>
</html>

I hope you get an idea about jquery split array.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.