The basic types of packaging types

ECMAScript offers three special reference type Boolean, Number, and String as a primitive type boolean, number, string type of packaging.

1、Boolean

var b = new Boolean(true);

valueOf (): returns true or false base type

toString (): returns the string "true" or "false"

 

2、Number

var n = new Number (10);

valueOf (): returns the value of the basic types of objects represented by

toLocaleString () \ toString (): Returns a string value, toString (base) can be specified binary radix, it returns the string of binary numbers

toFixed (count): Specifies the number of decimal places. Less original digits, padded; the original multi-digits, rounding

toExponential (count): Returns the exponential form, and specify the number of decimal places with rounding

toPrecision (count): number of significant digits specified value, the return value may be the format index, the general format may, have rounded

 

3、String

var str = new String("hello");

length: property, returns the number of characters contained substring, a character can be considered double-byte character

valueOf (), toLocaleString (), toString (): returns the object represented by the basic value of the string

charAt (pos): Returns a string of characters in a given position (single-character string) may be the same as access to a single character string for accessing the array, string [index]

chartCodeAt (pos): Returns a string given position of character encoding

concat (str [, str1 [, str2 ...]]): one or more strings spliced ​​together to obtain a new string without affecting the original string. More or string concatenation operator with a plus sign (+)

slice (start [, end]): Returns the specified position of the source string section substring, does not affect the source string. When the second argument default, the end position at the end. If the parameters are passed in the negative, the length of string passed negative value is added

substring (start [, end]): Returns the specified position of the source string section substring, does not affect the source string. When the second argument default, the end position at the end. If the incoming parameters are negative, all negative to the incoming 0

substr (start [, length]): Returns the specified position of the source string section substring, does not affect the source string. When the second argument default, the end position at the end. If the parameters are passed in a negative value, a negative value and the string length of the first addition, the second negative to 0

indexOf (str [, start]): From the beginning of the source string searching backwards given sub-string, and returns the substring of a first character in the source string, and if there are none -1. If there is a second argument, the given location to start the search

lastIndexOf (str [, start]): search forward from the end of the source string in a given sub-string, and returns the first character position of the first substring in the source string, and if not, return -1. If there is a second argument, the given location to start the search

trim (): Returns a new string, and remove all spaces both ends of the head and tail, does not affect the source string.

toLowerCase (): String lowercase letters are transferred

toUpperCase (): String uppercase letters are transferred

toLocaleLowerCase (): according to the language runtime environment, small letter

toLocaleUpperCase (): according to the language runtime environment, uppercase letters turn

match():

search():

replace():

split():

localeCompare (str): Comparison string argument string, returns a positive number, 0, negative. Equivalent (String - parameter string), at the back of the large alphanumeric value.

fromCharCode (c1 [, c2 [, c3 ....]]): receiving one or more character codes, and then converted to a string.

Guess you like

Origin www.cnblogs.com/zhanglw456/p/11275981.html