reduce example split string js
Example 1: javascript split string
// Split string into an array of strings
const path = "/usr/home/chucknorris"
let result = path.split("/")
console.log(result)
// result
// ["", "usr", "home", "chucknorris"]
let username = result[3]
console.log(username)
// username
// "chucknorris"
Example 2: javascript split
var names = 'Harry ;Fred Barney; Helen Rigby ; Bill Abel ;Chris Hand ';
console.log(names);
var re = /\s*(?:;|$)\s*/;
var nameList = names.split(re);
console.log(nameList);