split() method

Home   »   split() method

//  split() method:
const string = "I love to do work using react";
const result1 = string.split(" ");
console.log(string[1]) // result = " " // white space
console.log(result1[1]) // result = love
const result2 = string.split("");
console.log(result2[2]) // result = l
const result3 = string.split();
console.log(result3) // result = [ 'I love to do work using react' ]

Leave a Reply

Your email address will not be published. Required fields are marked *