javascipt split string code example
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: in javascript how to split string
var str = 'It iS a 5r&e@@t Day.'
var array = str.split(" ");
print(array);
var str = 'It iS a 5r&e@@t Day.'
var array = str.split(" ",2);
print(array);