nodejs string split code example
Example 1: javascript split
var arr = foo.split('');
console.log(arr);
Example 2: node js split
str.split([separator[, limit]])
Example 3: js split string
var myString = "Hello World!";
var splitWords = myString.split(" ");
var hello = splitWords[splitWords.indexOf("Hello")];
Example 4: split string
const str = 'The quick brown fox jumps over the lazy dog.';
const words = str.split(' ');
console.log(words[3]);
const chars = str.split('');
console.log(chars[8]);
const strCopy = str.split();
console.log(strCopy);
Example 5: node js split
function splitString(stringToSplit, separator) {
var arrayOfStrings = stringToSplit.split(separator);
console.log('The original string is: "' + stringToSplit + '"');
console.log('The separator is: "' + separator + '"');
console.log('The array has ' + arrayOfStrings.length + ' elements: ' + arrayOfStrings.join(' / '));
}
var tempestString = 'Oh brave new world that has such people in it.';
var monthString = 'Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec';
var space = ' ';
var comma = ',';
splitString(tempestString, space);
splitString(tempestString);
splitString(monthString, comma);