js split string on character 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: 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 3: javascript separate string by char

var Str = "Hello There!"
var SplitOn = " "
var Results = Str.split(SplitOn);
//Results[0] will be 'Hello' and Results[1] will be 'There!'

Example 4: how to split a string in javascript

strName.split(); // My code

Tags:

Php Example