On ES6 - A New Method string, a regular expansion, expansion value

 

new method:

1.repeat (), represents the original string is repeated n times, n is a parameter, decimal rounding, infinite error, negative error, take greater than -1 0 (null), NaN3 takes 0, the string into digital.

2.padStart (), padEnd (), fill the whole length, the first length parameter is added, the second parameter is a character supplemental content, the second parameter is omitted, the default spaces completion. Often used to complement a specified number and prompts string format.

3.trimStart (), trimEnd (), remove the spaces before and after the actual content. Valid for line breaks and invisible blank sign.

Regular:

1. The second parameter may (modifier) ​​and a parameter (regular expression) of different format when new RegExp, as the first argument is positive (with modifiers), the second string. Regular modifier in the first parameter is the second parameter modifier covered.

2.u modifier may be identified unicode characters (with the use of the back): dot character, matches any character identification code can add u greater than 0xFFFF. {U} represents the code quantifier, also need to add the predefined identification greater than 0xFFFF u, u may also be added to distinguish the character similar situation may also not escaped characters (\, so) error.

3.y modifiers, different from the g modifier. g modifier is not required position, after the first match may be selected to match any character back. y modifier must match the rest of the string head. Y modifier when used, in a replace () method, a regular parameter is:

const REGEX = /a/gy;
'aaxa'.replace(REGEX, '-') // '--xa'

Here's why only the replacement is aaxa make the middle of a x x y modifier find third found after the second stops a direct match. y modifier must match in order to return all used in conjunction with the g modifier. In addition y modifiers can jump directly match illegal matching error, the principle is the head of a match.

4. The operator can point modifier s complete match any character, including newline.

The first assertion "means that xonly the yonly match in front, must be written /x(?=y)/. For example, only matching numbers before the percent sign, should be rewritten /\d+(?=%)/." First negative assertion "means that, xonly not in yfront of the only match, must be written /x(?!y)/. for example, only matching numbers before the percent sign is not to be written /\d+(?!%)/. "underwent asserts that" coincided with the "first assertion" on the contrary, xonly yjust behind the match, must be written /(?<=y)x/. for example, only matching numbers after the dollar signs to be written /(?<=\$)\d+/. "underwent negative assertion" is the "first negative assertion" On the contrary, xonly not yonly match the back, must be written /(?<!y)x/. for example, only matching numbers following the dollar sign is not to be written /(?<!\$)\d+/.

Value:

1. 0o, 0b (letters can be uppercase) represent octal and binary, strict mode will complain, converted to decimal using Number () method.

2.Number.isFinite (), Number.isNaN (), Number.parseInt / parseFloat () method before the method is substantially no difference, the only difference is the type Number values ​​must be converted, the conversion value of the parameter, for the purpose of doing so is let modular language.

3.Number.isInteger (), if the sensed value is an integer, are also considered 15.0 integer, true value is not an integer not after the decimal point are discarded, resulting in 16-bit value of the 16 bits is not 0 will be ignored, and identified as an integer, It will be less than the identification number that is an integer of 0 is considered.

4.Number.EPSILON, a very small constant, typically for detecting the error is within the allowable range, for example, an error range is set to -50 th power of 2 (i.e., Number.EPSILON * Math.pow(2, 2)).

5.Number.isSafeInteger (), determines whether or not the integer (53-th power of 2), and in essence the boundary values ​​are compared within the safety integer.

Today to this first.

Guess you like

Origin www.cnblogs.com/harrywu96/p/12125125.html