js method of splitting a string and putting the split data into an array

  • 2020-06-07 04:01:12
  • OfStack

This article example shows how js splits strings and puts the split data into arrays. Share to everybody for everybody reference. Specific implementation methods are as follows:

var splitArray = new Array();
var string=" Pacific Ocean, Atlantic Ocean, Indian Ocean, Arctic Ocean ";
var regex = / , /;
for(i=0; i < splitArray.length; i++){
 document.write(splitArray[i] + "<br>");

Hopefully, this article has been helpful in your javascript programming.

Related articles: