Learning Goals
1. Mastering the String Object method:
CharAt ()
charCodeAt ()
IndexOf ()
Lastindextof ()
CharAt () and
Grammar:
Stringobjcet.charat (Index)
Function:
returns a string from the index position in the stringobject.
Description
ECMAScript5 can use "square brackets and string indexes" to access specific characters in a string, but IE7 and earlier browsers return undfined.
charCodeAt ()
Grammar:
Stringobject.charcodeat (Index)
Function:
returns The character encoding of the index position character in Stringobject.
Description
ECMAScript5 can use "square brackets and string indexes" to access specific characters in a string, but IE7 and earlier browsers return undfined.
IndexOf ()
Grammar:
Stringoject.indextof ("0")
Function:
Searches a string for the given substring, returning the location of the substring.
return value: Numeric
Description: Returns 1 if the substring is not found .
Learning Goals
1. grasp the method of intercepting the string object:
Slice ()
SUBSTRING ()
SUBSTR ()
Slice ()
Grammar:
Stringvalue.slice (Start,end)
Function:
Truncate substring
Parameter description:
1.start: required to specify the starting position of the substring.
2.end: Optional, indicates where the substring ends, end itself is not within the intercept range, and is truncated to the end of the string when omitted.
3. when the parameter is negative, the passed-in negative value is added to the length of the string.
SUBSTRING ()
Description: The syntax and function are exactly the same as slice () .
The difference is:
1. when the parameter is negative, the parameter is automatically converted to 0.
2.Substring () takes a smaller number as the starting position and a larger number as the end position.
SUBSTR ()
Grammar:
Intercepts a substring.
Parameter description:
1.start: required to specify the starting position of the substring.
2.len: Optional, indicates the total number of characters intercepted, and the end of the string is truncated when omitted.
3. when star is negative, the pass-through is added to the length of the string.
4. when len is negative, an empty string is returned.
Learning Goals
Mastering the comprehensive application of the string method:
Write The JS function, which gets the suffix name of the input parameter, such as input abc.text, returns . Text.
Learning Goals
1. How to Master A String object:
Split()
Replace()
Split ()
Grammar:
Stringobject.split (separator)
Function:
Splits a string into a string array.
return Value: Array
Description
Separator: required, separator.
Replace()
Grammar:
Stringobject.replace (regexp/substr,replacement)
Function:
Substitute some characters in the string for some other characters. or replace a character that matches a regular expression.
return value:string
Parameters:
RegExp: Required, specifies the substring or RegExp object of the pattern to be replaced .
Replacement: required, a string value.
Learning Goals
Other ways to master string methods:
1.toUpperCase ()
2.toLowerCase ()
3. convert string border-left-color to borderleftcolor
toUpperCase () and tolowercase ()
Grammar:
Stringvalue.touppercase ()
Function: Converts a string to uppercase.
Syntax:stringvalue.tolowercase ()
Function: Convert the string to lowercase.
Built-in objects in JavaScript -8-string-2