JavaScript Learning Notes

Source: Internet
Author: User

  1. JavaScript does not enforce the requirement to add at the end of each statement ; , and the engine responsible for executing JavaScript code in the browser automatically complements the end of each statement ; .
  2. JavaScript is strictly case sensitive
  3. The type of variable itself is called Dynamic language, and it corresponds to static language. Static languages must specify the variable type when defining the variable, and if the type does not match, an error is given. For example, Java is a static language and JavaScript is a dynamic language.
  4. If a variable is used without a var declaration, the variable is automatically declared as a global variable. In different JavaScript files on the same page, if you do not have var to declare it, the variables i will be used, causing i the variables to interact with each other, resulting in hard-to-debug error results.
  5. JavaScript code that runs in strict mode, which is enforced by var declaring variables that are var used without declaring variables, will result in run errors. The way to enable strict mode is to write on the first line of the JavaScript code:‘use strict‘;
  6. Browsers that do not support strict mode will execute it as a string statement, and browsers that support strict mode will turn on strict mode to run JavaScript. Variables that are not var declared are considered global variables, and in order to avoid this flaw, all JavaScript code should use the strict pattern.
  7. Multi-line string: Because the multiline string is more \n cumbersome to write, the newest ES6 standard adds a multi-line string representation, using ' ... ' means
  8. Template string: If there are many variables that need to be connected, + it is more troublesome to use the number. ES6 adds a template string that represents the same method as the multiline string above, but it automatically replaces the variables in the string:
    var message = `你好, ${name}, 你今年${age}岁了!`;
  9. The string is immutable, and if you assign a value to an index of a string, there is no error, but there is no effect:

    var s = ‘Test‘;s[0] = ‘X‘;alert(s); // s仍然为‘Test‘

JavaScript Learning 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.