OneBite.Dev - Coding blog in a bite size

split a string by comma sign in Javascript

Code snippet on how to split a string by comma sign in Javascript

  let myString = "this,is,a,sample,string";
  let splitString = myString.split(",");

This code demonstrates how to split a string by comma sign in Javascript. The first line creates a string called myString containing comma-separated values. The second line uses the split() method to break the string up into an array of substrings using the comma as the delimiting character. The split() method returns an array of strings split at the specified delimiter. The result will be an array containing each of the words in the string, in order.

javascript