Q. Which of the following functions of “String” object divides a String object into an array of strings by separating the string into substrings?
β
Correct Answer: (B)
split()
Explanation: split() – Splits a String object into an array of strings by splitting the string into substrings. Example:
var str = "Hello world!";
var res = str.split(" "); //Hello,world!