JavaScript contains a small number of standard methods that can be used on standard types.
Array
Array.concat (item ...) it contains a shallow copy of the array and attaches 1 or more parameter item after it.
The Array.join (separator) Join method constructs an array into a string that constructs each element in an array into a string, joins them together with separate as a delimiter, and the default separate is ",", For a non-interval connection, you can use an empty string as the separate.
Array.pop () removes the last element in the array and returns the element
Array.push (ITRM ...) Appends one or more parameter item to the tail of an array
Array.reverse () Reverses the order of the elements in the array and returns the current array
Array.shift () shifts the first element in an array of arrays and returns the element, and if the array is empty, it returns Undefined,shift, which is usually much slower than the pop.
Array.slice (Start,end) slice method for shallow copy, the end parameter is optional, and the default value is the length of the array, if any of the two parameters are negative, Array.Length will and they want to add to try to make them non-negative. If start is greater than or equal to array.length, the resulting result will be a new empty array.
The default comparison function of Array.Sort (COMPAREFN) JavaScript assumes that all elements to be sorted are strings, and that it does not detect their type before comparing elements, so when it compares these numbers it converts them into strings, resulting in an incorrect result.
However, you can use your own comparison function to replace the default comparison function.
var n = [4,23,16,8,42,15];n.sort (function (b) { return A- b;}); //n is [4,8,15,16,23,42];
But it cannot sort strings.
Array.splice (Start,deletecount,item ...) the splice method removes 1 or more elements from the array, replaces them with a new itemt, and the argument start removes the start position of the element from the array. The parameter delete count is the number of elements to remove, and if there are additional parameters, those items are inserted at the location of the removed element, which returns an array containing the removed elements.
Array.unshift (Item ...) inserts the item into the beginning of the array, returning the new length value of the array.
Function
Function.apply (Thisarg,argarray) The Apply method invokes function functions, passing an object that will be bound to this and an optional array of arguments. The Apply method is used in the Apply invocation pattern.
Number
The Number.toexponential (fractiondigits) Toexponential method converts this number to a string in exponential form, and the optional parameter fractiondigits controls its digits after the decimal point. Its value must be between 0-20
The number.tofixed (fractiondigits) ToFixed method converts number to a string in decimal form, and an optional parameter fractiondigits controls the number of digits after the decimal point, whose value must be between 0-20 and the default is 0 ;
The number.toprecision (Precision) Toprecision method converts number to a string in decimal form, and the optional parameter fractiondigits controls the number of digits after the decimal point, and its value must be between 0-21.
The number.tostring (Radix) ToString method converts number to a string, the value of radix controls the cardinality, its value must be between 2-36, the default radix is 10 radix, and the radix parameter is the most commonly used integer, But he can use any number.
Object
Object.hasownproperty (name) checks if object contains name, contains a return of true, the same name property in the prototype chain is not checked, so he has no effect on hasownproperty.
Regexp
The Regexp.exec (String) Exec method is the strongest and slowest way to use regular expressions. If it succeeds in matching regexp and string strings, it returns an array with the element labeled 0 in the array containing the regular expression regexp matching substring. The element labeled 1 is the text captured by grouping 1, the element labeled 2 is the text captured by grouping 2, and if the match fails, it returns NULL.
Regexp.test (String) test is the simplest and quickest method to use in regular expressions. If the regexp matches a string, it returns true, otherwise it returns false and does not use the G flag for this method.
String
The String.charat (POS) CharAt method returns a string that is at the POS position at the point where the POS is less than 0 or greater than the length of the string string.length, which returns an empty string.
String.charcodeat (POS) The character code point of the character at the POS position in a string, expressed as an integer. If the POS is less than 0 or greater than the length of the string string.length, it returns Nan.
String.Concat (String ...) Link string
String.IndexOf (Searchstring,position) finds another string searchstring in string, returns the position of the first matching character if it is found, otherwise returns-1.
String.LastIndexOf (searchstring,position) is similar to indexof, and it is searched from the end of the string.
String.localecompare (that) comparison string
String.match (RegExp) matches strings and regular expressions, and if there is no G flag, the result of calling String.match (RegExp) is the same as the result of calling Regexp.exec (string), however, if RegExp has a G flag, Then it returns an array containing all the matches except the capturing packet.
String.Replace (Searchvalue,replacevalue) operation to find and replace string and return a new string
String.search (RegExp) is similar to the IndexOf method except that it accepts a regular expression object as a parameter instead of a string
String.slice (Start,end) copies part of a string to construct a new string
String.Split (Separator,limit) separates the string into fragments to create an array of strings, and the optional parameter limit limits the number of fragments to be split.
String.substring (Start,end) is the same as the slice method
String.tolocalelowercase () returns a new string, using localization rules to convert string to lowercase format
String.tolocaleuppercase () returns a new string, using localization rules to convert string to uppercase format
String.tolowercase () Convert string to lowercase format
String.touppercase () Convert string to uppercase format
String.fromCharCode (char ...) Returns a string from a series of numbers
JavaScript Language Essence _ Eighth Chapter