This is the third day of my participation in the August More text Challenge. For details, see: August More Text Challenge

Follow the rhythm and study a little every day! Consolidate the basic knowledge of learning JavaScript, deepen the understanding of memory, to build a firm foundation! Come on

Most of the content for the vernacular content, the basic knowledge with their own understanding, simple and comprehensive summary of the basic knowledge, convenient to deepen understanding!

For more detailed learning – see mdN-javascript documentation, (Little Red Book/White Paper/Blue Book /..) Learn to advance!

Read more: Previous update review

Day1 (1)

Day1 (2)

Let’s move on to JavaScript Day2

First, comb knowledge points

1. Data types in JS

number string boolean object function null undefined

Operators and expressions

  • Logical operators && | |!

  • Relational operators: >>= <= ==! = = = =! = =

  • Arithmetic operator: + “100” + 90

  • =   +=  sum += 0;  sum = sum + 0;

  • Condition: Expression 1? Expression 2: Expression 3

3, js represents true or false:

4. Js definition

  • Variables and Constants
  • Naming conventions for identifiers

Operator precedence

() > Monocular (++ –!) > Arithmetic > Relationships > Logic > Conditions > Assignment =

3, short circuit phenomenon (expansion)

When true | |, that is, true | | and | | on the right side of the expression does not perform When false &&, i.e., false &&, && on the right side of the expression does not perform

4. Data type conversion

4.1 Automatic type conversion (automatic conversion at runtime of JS code) :

  • A purely numeric string is automatically converted to a numeric value when performing an arithmetic operation or a relational operation
  • When doing arithmetic, null is automatically converted to 0 and undefined is automatically converted to NaN
  • null + 9 —> 9    undefined + 9 —> NaN

4.2 Casting:

  • parseInt( ); An attempt was made to convert a string to an integer, and the result is Nan.eg. “3a” “a3”–>NaN
  • parseFloat( ); The result of an attempt to convert a string to a decimal is NaN
  • Number( ); The result of trying to convert a type to a numeric type and not converting properly is NaN
  • Boolean()An attempt was made to convert a type to a Boolean value
  • toString()To convert a type to a string, if you add 2 or 8 or 16 in parentheses, you do the base conversion –

4.3 Extension method:

  • IsNaN () determines non-numeric if the parentheses are non-numeric, the result is true, otherwise the result is false, if the parentheses are purely numeric strings, the result is automatically converted to numbers

    • isNaN(“23”)–> false
    • isNaN(“23a”) –> true
    • isNaN(23) — > false
  • Eval () attempts to convert a string into an expression and get the expression’s value

5, the three main structure of the program: order selection loop

  • Order: The program does not skip any statements from top to bottom
  • Select: Selectively execute a piece of code according to a condition
  • Loop: Execute repeatedly

6. Select structure (only one exit)

  • Control statement (single branch statement one condition) :
if(expression){statement1;
}else{statement2;
}
Copy the code

Note: Here expressions are generally relational expressions

Execution logic: If the result of the expression is true, an if statement is executed, otherwise an else statement is executed

  • Control statement (multiple branching statements with multiple conditions)
if(expression1 ){
  ...
}else if(expression2 ){
  ...
}else if(expression3 ){
  ...
}else{... }Copy the code

7. Several problems summarized by if

  • 1. If there is only one statement after the if, the curly braces can be omitted
  • Else (){} else(){} else(){
  • 3, else can be omitted

Study a little every day

Learning is a continuous process, stick to it, there will be harvest!

Accumulate over a long period of time, consolidate the foundation, early into dafang!

Calm Down & Carry On!