JS second week

Source: Internet
Author: User

Looping Statements

**1.while**

while (condition) {
Code executed when the condition is met
}
**2.do...while**

do{
Code to execute
}while (condition)
**3.for**

3.1 for (initialization expression; conditional-judgment expression; change loop-condition expression) {
Code to execute
}
3.2 Iterating through an array
Example: Let arr=[' 1 ', ' 2 ', ' 3 ']
for (let i=0;i<arr.length;i++) {
Console.log[i];
}
3.3 Interrupt Loop
        break
         Example: for (let i=0;i<10;i++) {
Span style= "COLOR: #008000" >                                 if (i==5) {
                                          break; /continue;
         break is a direct end to the entire loop, and only interrupts the nearest loop from his
         continue end of current round loop

JS. First Class
**1. Notes * *
A. Single-line comment: Double slash/middle is comment content/, only in current line
B. Multi-line Comment:/* The middle is the content of the comment */, can be many lines
**2. Identifiers * *
A. Rigid requirements
-can consist of letters, numbers, underscores, and dollar signs, no other special symbols are allowed
-Cannot start with a number
-Prohibit use of keywords and reserved words in JavaScript
-Strictly case-sensitive
B. Soft requirements
-Wang Wen Zhi-yi
-Using the Hungarian nomenclature, the Hump nomenclature, the Snake name method
**3. Data type Introduction * *
ES5
A. Strings string
B. Number
C. Boolean Boole results only true and false
D. Undefined not defined
E. NULL null
ES6 New
F. Unique symbol
G. Object
A-F: Basic data (simple data)
G: Reference data (complex data)
**4. viewing Data types * *
Example: Console.log (typeof data);

**5. Variables * *

Meaning: A container for storing data that can be changed in the presence of variables

A. Declaration of a variable (created)

ES5:

Example: Var A;

ES6:

Example: let A;
B. Variable initialization

Example: let c=123; (give a value at the beginning)
C. Issues with variable declarations

-Duplicate Declaration
-Omission Statement
-Continuous Declaration

**6. Scope of Variables * *

is the scope of the variable.
Divided into global scope, local scope
Local scope of ES5: partitioning by functions
Local scope of ES6: by curly Braces
Free variable: A variable declared outside the current scope, which is called a free variable for the current scope

**7. Variable Lift * *

Before all code runs once, there is a process to parse the code (browse but not run). In this process, all variables declared through Var are found, and the declaration of the variable is promoted to the head of the code (the assignment of the variable remains in the original position)

**8. Constants * *

Example: const a=1;
Constant declaration must be initialized at the same time
Modifying values is not allowed
Duplicate declarations are not allowed

The difference between **9.var and let * *

A.var allow duplicate declarations, let do not allow
B.var scopes are distinguished by functions, let is distinguished by braces
C.var allows variable elevation, let does not allow








JS second week

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.