Scope of a function
Global Variables
在页面的任何地方都能访问到的变量,拥有全局的作用域
- The outermost layer of the variables defined functions
- There is no direct variable assignment with Global Properties
Local variables
只能在固定的代码片段中访问到
- Variables defined inside the function;
- Parameters are also local variables
return
To a function returns a value, and terminates the current function out
return return value
- The return value can be any data type
- You can only return a return value
- If no return value, the default value is undefined
recursive function
It calls itself inside the function
JavaScript functions built top
escape () non-alphanumeric characters are encoded
unescape () for decoding the encoded string
- Number () is converted into numeric types
- If it is a Boolean value, false is 0, true 1
- If it is digital, converted into itself. The rear guide meaningless 0 removed.
- If null converted to 0
- If this is undefined is converted to NaN not a number
- If a string
- If a string which only the number is converted to decimal (0 ignore leading and trailing guide 0)
- If the norm is valid floating-point, floating-point value is converted into (0 ignore leading and trailing guide 0)
- If the string is empty, then converted to 0
- If other values, return NaN
- String () is converted into a string type
- You may convert any type String
- null and undefined: will be converted to a string, are null and undefined
- Boolean: true and false returns
- Value Type: string itself
- Boolean () is converted into Boolean type
- Conversion is false: "", 0, NaN, undefined, false, null
- Others are converted to all true.
- the parseInt () to convert the string to an integer
- If a string contains only numeric, decimal places conversion manner integer
- Automatically ignore spaces in front of the string until it finds the first non-empty string value, if the first character string is not a space, digital, - then return NaN
- parseFloat () is converted to a decimal
- Among the string of only the first valid, others are invalid
- If the string is a valid integer, his return is an integer, floating point numbers will not return
- () Determines whether a number is converted to numeric type isNaN
- If the energy is converted to the value FALSE, the type of value that can not, returns true
JavaScript data cast
- Number () is converted into numeric types
- String () is converted into a string type
- Boolean () is converted into Boolean type
- the parseInt () to convert the string to an integer
- parseFloat () is converted to a decimal
Data type conversion Implicit
- Arithmetic Operators
- Relational Operators
- Logical Operators
- if
- while
- A triplet of expressions