Brief introduction:
Description: JS provides three special reference types: Boolean, number, String, when assigned to a variable as a primitive type object, the background creates an object of the corresponding base wrapper type, enabling you to invoke some methods to manipulate these types of data
Literal create var content = ' I love you! ' var subcontent = content.substring (2) Console.log (subcontent)//new string Create var content = new String (' I love you! ') var subcontent = content.substring (2) console.log (subcontent)
Note: You can see from the above that both the wrapper object created by the default literal or the reference type object created by new are properties and methods, but it is important to note that the wrapper object created by the literal cannot add properties and methods, only the reference type object created by new supports adding properties and methods.
Boolean type:
Description: The Boolean type does not have a specific property or method
Number type:
Description: The number type has some static properties (directly from the property called by number, ignoring the new operator) and methods
Static properties |
Max_value |
Represents the maximum number |
Min_value |
Represents the minimum value |
NaN |
Non-numeric |
Negative_infinity |
Negative infinity, overflow returns this value |
Positive_infinity |
Infinity, Overflow returns this value |
Prototype |
Prototypes. For adding new properties and methods |
Object methods |
ToString () |
Converts a value to a string, and can be converted into a binary |
toLocaleString () |
Converts to a string based on a local number format, separated by a three-bit separated comma |
ToFixed () |
Preserves a number by specifying the number of digits after the decimal point and converting it to a string, expressed as a normal floating point |
String type:
Object Properties |
Length |
Returns the character length of a string |
Constructor |
Returns the function that creates a String object |
Prototype |
Extending a string definition by adding properties and methods |
Static methods |
fromCharCode (ASCII) |
static method, output ASCII code corresponding character |
Localecompare (STR1,STR2) |
Compares two strings and returns a corresponding value 1/0/-1 |
Character method |
CharAt (N) |
Returns the character of the specified index position |
charCodeAt (N) |
Returns the character in Unicode encoding at the specified index position |
Object methods |
Concat (STR1...STR2) |
Concatenates string arguments into a string that invokes the method |
Slice (n,m) |
String that returns the position of the string N to M |
SUBSTRING (n,m) |
String that returns the position of the string N to M |
SUBSTR (n, m) |
Returns the M string starting with the string n |
IndexOf (str, n) |
The first str is searched starting from N, and the index value of the search is returned, if not found returns-1 |
LastIndexOf (str, n) |
Search for the last str from N, and return the search index value if not found returns-1 |
toLowerCase (str) |
Convert all strings to lowercase |
toUpperCase (str) |
Convert all strings to uppercase |
toLocaleLowerCase (str) |
Converts the string all to lowercase, and localization |
toLocaleUpperCase (str) |
All strings are converted to uppercase, and localized |
Match (pattern) |
Returns a substring in pattern or null |
Replace (pattern, replacement) |
Replace pattern with replacement |
Search (pattern) |
Returns the start position of the pattern in a string |
Split (pattern) |
Returns an array of strings that are split by the specified pattern, and if the pattern is "to convert a string to a character array |
Localecompare (str) |
Compares two strings and returns a corresponding value 1/0/-1 |
HTML method |
Http://www.w3school.com.cn/js/js_obj_string.asp |
var flag = ' xx ' var posarr = []var STRs = ' xxooxxooxxooxxooxxooxxo '//First get string first occurrence position var firstpos = strs.indexof (flag, 0)// If not found on breakwhile (firstpos! =-1) {//First print substring and then get position Console.log (Strs.substr (Firstpos, flag.length)) Firstpos = s Trs.indexof (flag, Firstpos+flag.length)}
This article is from the "ζ Automated operation and maintenance development Road ζ" blog, please be sure to keep this source http://xmdevops.blog.51cto.com/11144840/1851416
Website Front End _javascript.0013.javascript Package type