- String splicing
- = =
- If statements and logical operations
String splicing
const a = 100 + 10 // 110
const b = 100 + '10' // '10010'
const c = true + '10'// 'true10'
Copy the code
The = = operator
100 == '100' //true 0 == "//true 0 == false //true false ==" //true null == undefined //true // Const obj = {x:100} if (obj. A == null){... } / / equivalent to the if (obj. A = = = null | | obj. = = = a undefined) {... }Copy the code
If statements and logical operations
- The TRULY variable:!! A === true
- Services Variable:!! A === false variable
Const a = 100(truly variable)! n //false !! N //true service constant n1 = 0(server variable)! n1 // true !! n1 //false !! Null (Service variable)!! Will service variable!! NaN (Service variable) -> not a number but of type number!! '(Service variable)!! {} (TRULY variable) Everything else is TRULY variable will we judge TRULY variable or truly variable within our IF (); It's not true or flaseCopy the code
Logic & | |! With or not
console.log(true && false)// false console.log(10 && 0)//0 console.log(true || false)// true console.log('abc' || '')// 'abc' console.log(! false)// true console.log(! window.abc)// trueCopy the code