JavaScript Advanced Programming Notes

Source: Internet
Author: User

1.1 JavaScript History <script>
    • Async/defer can control the JS loading sequence
    • Put the JS file at the bottom of the page to speed up page opening
3 Basic Concepts
    • Grammar
    • Data type
    • Flow control Statements
    • Understanding functions
3.4 Data types
    • Six types of data are defined in ECMAScript: underfined, Null, Boolean, number, String, Object
    • Using the typeof keyword to detect types
//boolean () conversion
var bool1 = Boolean (true);
var bool2 = Boolean ("");
var bool3 = Boolean (0);
var bool4 = Boolean (null);
var bool5 = Boolean (BOOL5);
alert (bool1+ "+bool2+" "+bool3+" "+bool4+" "+bool5"); Output:true false false false false  Number: range from 5e-324 to 1.79e+308, out of range becomes infinity
    • NaN (not a number) indicates a case where the operand that would have returned a numeric value did not return a numeric value. In other languages, except for 0, an error will be returned, but in ECMAScript, except 0, the program will continue to execute.
//number () conversion
var num1 = number ("Hello world!");
var num2 = number ("");
var num3 = number ("000011");
var num4 = number (true);
alert (num1+ "+num2+ " "+num3+" "+num4"); Output:nan 0 14.3 Execution environment and scope each function has its own execution environment. When the code executes in an environment, it creates a scope chain for the variable object.          A variable object that contains its own variable object and global environment in the scope chain. There is no block-level scope in JS, so so the JS scope is bounded by functions rather than curly braces.7.2 Closures So understanding closures first understand the scope chain, because the scope chain of a closure contains variable objects for external functions. 7.2.1 Closures and variables closures can only get the last value that contains any one of the variables in the function. As an example:7.2.2 This object is not read. 14 Form Scripts 14.1.3 form fields Here, the code test is not the same as the book.
        function () {            var form =  document.getElementById ("Form1");             var colorfields = form.elements["Color"];            alert (colorfields.length);             var firstfield = colorfields[0];             var firstformfield = form.elements[0];             = = = Firstformfield); False, the book is True        }

JavaScript Advanced Programming Notes

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.