String

var name = new String("Jack Black");
//or var name = "Jack Black";
alert("A. Name: " + name);

//Same as length() in Java
alert("B. Name's Length: " + name.length);

//Returns the character at index 1,Same as Java
alert("C. " + name.charAt(1));

//Return the character code of the index, Same as codePointAt() in Java
alert("D. " + name.charCodeAt(1));

alert("E. " + name.concat(",Anne Bonny"));//Same as Java

//Returns the index of "Black",Same as Java
alert("F. " + name.indexOf("Black"));

//Search from index 0 to the left,Same as Java
alert("G. " + name.lastIndexOf("Black",0));

//Returns a string that matches the regular expression
alert("H. " + name.match(/Black/));

//Similar to Java's replaceAll()
alert("I. " + name.replace("Black","White"));

//Returns the index of the string that matches the regular expression
alert("J. " + name.search(/Black/g));
alert("K. " + name.slice(1,2));//Java's substring(int, int)
alert("L. " + name.slice(1));//Java's substring(int)

//The array of JavaScript is separated by commas.
//Similar to Java's split()
alert("M. " + name.split(" "));

alert("N. " + name.substring(1,2));//Same as Java
alert("O. " + name.toUpperCase());//Same as Java
alert("P. " + name.toLowerCase());//Same as Java