1. Be sure to use the var keyword when assigning a value to a variable for the first time
If the variable is not declared but assigned directly, it will be regarded as a new global variable by default. Avoid using global variables as much as possible.
2. Use === to replace ==
The == and != operators will automatically convert data types when needed. But === and !== will not, they will compare values and data types at the same time, which also makes them faster than == and !=.
[10] === 10 // is false
[10] == 10 // is true
'10' == 10 // is true
'10' === 10 // is false
[] == 0 // is true
[] === 0 // is false