JavaScript advanced Programming--Basic concepts--notes

Source: Internet
Author: User

Statement

    1. The IF statement automatically calls the Boolean () conversion function to convert the result of the expression to a Boolean value
    2. 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
    3. Any data type can be used in a switch statement, whether it is a string or an object, and secondly, each
    4. 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

      1. 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
      2. 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
      3. All parameters in the ECMAScript are passed as values, and arguments cannot be passed by reference
      4. 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.
      5. In strict mode, assignment to arguments becomes invalid, and second, overriding arguments can result in syntax errors
      6. 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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.