split in array code example

Example 1: javascript explode

//split into array of strings.
var str = "Well, how, are , we , doing, today";
var res = str.split(",");

Example 2: split array javascript

// Returns new array from exising one
arr.slice(start, end);

Example 3: split() javascript

let countWords = function(sentence){
    return sentence.split(' ').length;
}

console.log(countWords('Type any sentence here'));

//result will be '4'(for words in the sentence)

Example 4: how to slip array

import numpy as np # import some stuffs

arr = np.array([1, 2, 3, 4, 5, 6]) #create array


newarr = np.array_split(arr,3); # split the array up to 3
print(newarr)