JavaScript study notes (1) Operators

 1. Operators

 

Operators are symbols used to implement assignments, comparisons, and perform arithmetic functions.

  • Arithmetic operators: + - * / %
  • Increment and decrement operators ++, --
  • Comparison operators: >, <, >=, <=, ==, !=, === (all equal to)
  • Logical operators: &&, ||, !
  • Assignment operators: =, +=, -=, %=, *=

1. Arithmetic operators

There is a precision problem in floating-point calculation, which is a problem at the bottom of the computer. So don't judge if two floats are equal

2. Increment and decrement operators

It is divided into pre-increment and post-increment, and it is the same when used alone

Pre-increment first self-increment before assignment, post-increment first assignment and then increment. Pay attention to the priority order of expression operations

var p = 10

console.log(++p + 10)//return 21

console.log(p++ + 10)//return 20

3. Comparison operators

== There is a default conversion data type, which will convert string type data to digital type

console.log('18'==18)  //true

console.log('18'===18) //false

4. Logical operators

It seems nothing special

5. Assignment operator

nothing special

6. Operator precedence

Logical AND > Logical OR

Guess you like

Origin blog.csdn.net/weixin_44400887/article/details/123881496