jquery split string to array – How to split string to array by comma using jquery?

jquery split string to array : Use the split() Method splits a string into an array of substrings, and returns the new array. It splits a String object into an array of strings.The split() method returns the new array.

jquery split string to array

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

Example

<!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 plyerDetails = "P,A,K,A,I,N,F,O,C,O,M";
   
    console.log(plyerDetails.split(','));    
   
</script>
</body>
</html>

Don’t Miss : jquery split string to array

Free Live Chat for Any Issue

How to Convert Comma Separated String into an Array in JavaScript

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Convert Comma Separated String to Array in JavaScript</title>
</head>
<body>
    <script>
    var names = 'pakainfo,w3school,infinityknow,w3diy,tamilrokers,New website';
    var websArrayData = names.split(',');
    console.log(websArrayData);
     
    document.write(websArrayData[0] + "<br>"); 
    document.write(websArrayData[1] + "<br>");
    document.write(websArrayData[websArrayData.length - 1] + "<br>"); 
     
    var str = 'Welcome To Pakainfo!';
    var information = str.split('');
    console.log();

    document.write(information[0] + "<br>");
    document.write(information[1] + "<br>");
    document.write(information[information.length - 1]);
    </script>
</body>
</html>

I hope you get an idea about jquery split string to 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.

Rate this post