var str= "Hello World";
1 charAt () returns the first few subscript characters of a string
Console.log (Str.charat (4));
2:fixed () displaying strings in typewriter font
document.write (Str.fixed ());
3:indexof () returns the position of the first occurrence of a character or string fragment in the string, and returns 1 if it does not exist.
Console.log (Str.indexof ("w"));
Console.log (Str.indexof ("pp"))
4: Convert strings to uppercase and lowercase
Console.log (Str.touppercase ())//Uppercase
Console.log (Str.tolowercase ())//lowercase
The 5:substring (Star,stop) method is used to extract the character of a string intermediary between two specified subscripts.
A new string value that contains a substring of stringobject whose contents are all characters from start to stop-1, with a length of stop minus start
。
Console.log (Str.substring (4))//Starting with the 4th subscript, to the end of the string
Console.log (str.substring (2,5))//return subscript 2 to subscript 4 characters
6: Display the string as a subscript
document.write (Str.sup ())//superscript
document.write (Str.sub ())//subscript
7: Display string as Strikethrough
document.write (Str.strike ());
8:split, dividing a string into an array
Console.log (Str.split (""));
["Hello", "World"]
9 Slice (star,end), extracting a string fragment
Includes the string Stringobject all characters from start (including start) to end (not including end). Star is allowed to take negative numbers, and a negative number is calculated from the end
document.write (Str.slice (3,6))
Ten replace (A, a, a) is a regular rule that matches a string, and B is a string that needs to be replaced
Console.log (Str.replace (/hello/, "fuckb"));
JS Basic Review---string manipulation