Statement
- The IF statement automatically calls the Boolean () conversion function to convert the result of the expression to a Boolean value
- For-in the order of the property names for the loop output is unpredictable, the return order may vary by browser, and if the variable value of the object being iterated is null or undefined, the for-in statement throws an error and ECMAScript5 corrects the behavior; No longer throws an error in this case, but simply does not execute the loop body, in order to be compatible, to detect whether the value of the object is null or undefined before using the for-in loop
- Any data type can be used in a switch statement, whether it is a string or an object, and secondly, each
- The value of a case is not necessarily a constant, it can be a variable, even an expression
Understanding Parameters
You can pass any number of arguments to the function, and you can access them through the arguments object
-
- The arguments object is just similar to an array, but it is not an instance of arrays. Although the element can be accessed by subscript, the length property determines how many parameters are passed in, and the named parameter without passing the value is automatically assigned the undefined value
- Parameters named in Ecmascripta are only convenient but not required, and in the name of parameters, other languages may need to create a function signature beforehand, and future calls must be consistent with that signature, but in ECMAScript, there are no such rules, The parser does not validate named parameters
- All parameters in the ECMAScript are passed as values, and arguments cannot be passed by reference
- There's something more interesting about arguments's behavior. That is, its value is always kept in sync with the value of the corresponding named parameter. Because the values in the arguments object are automatically reflected in the corresponding named parameters, this is not to say that reading these two values accesses the same memory space, their memory space is independent, but their values are synchronized. However, this effect is unidirectional: Modifying a named parameter does not change the corresponding value in the arguments, and the length of the arguments object is determined by the number of arguments passed in, not by the number of named arguments defined by the function, if only one parameter is passed, then arguments[1] The value set will not be reflected in the named parameter.
- In strict mode, assignment to arguments becomes invalid, and second, overriding arguments can result in syntax errors
- By checking the type and number of incoming parameters and reacting differently, you can mimic the overloads of the method
JavaScript advanced Programming--Basic concepts--notes