JavaScript built-in top-level functions
Built-in: ECMAscript's own function, ECMAscript will often
With some of the features that we don't need to know how he did it.
, just know how to call it.
? The top layer, which can be called anywhere in the page.
1.escape () encodes non-alphanumeric and numeric characters
2.unescape () decodes the encoded string
3.Number () converted to numeric type
4.String () Convert to String type
5.Boolean () Convert to Boolean type
6.parseInt () Converts a string to an integer type
7.parseFloat () converted to decimal
8.isNaN () Determines whether a number can be converted to a numeric type.
9.eval () parsing string content with JavaScript syntax
1.escape () encodes non-alphanumeric and numeric characters
2.unescape () decodes the encoded string
function to encode a string so that it can be used on all computers
Reads the string.
Parsefloat () Converts a string to a floating-point number
A. In the string. Only the first one is valid and the others are invalid.
B. If the string is a valid integer, he returns an integer,
No floating-point numbers are returned.
Number () is converted to a numeric type
A. If it is a Boolean value, False is 0,true to 1
B. If it is a number, the conversion becomes itself. Remove the meaningless back guide 0.
C. If undefined is converted to Nan not a number
D. If it is a string
1. If there are only numbers in the string, convert to 10 (ignoring leading 0 and 0)
2. If it is a valid canonical floating-point type, convert to a floating-point value (ignoring leading 0 and trailing 0)
3. If it is an empty string, convert to 0
4. If it is a different value, return Nan
parseint (parameter 1, parameter 2) converts a string to an integer
A. If a string contains only a number, it is converted to an integer in 10-binary mode.
B. He automatically ignores the spaces in front of the string until it finds the first non-empty value
String, if the first character of the string is not a space, number,--then the return
Back to Nan
C. The second parameter is the number of digits that specify the first argument
String (parameter)
You can convert any type to a string
–null and undefined: will also be converted to strings, respectively
null and undefined
– Boolean type: Returns True and False
– Numeric type: string of itself
Boolean () to convert any type of value to a Boolean value
– Convert to False: "", 0, NaN, undefined, false,null
– All the others are converted to true.
IsNaN () is used to check whether its arguments are non-numeric values
If it can be converted to a value return false, cannot be converted to a numeric type, return
Really.
Eval () parsing string content with JavaScript syntax
var str = ' 1+2 ';
Alert (eval (STA));
JavaScript built-in top-level functions