Differences between using VaR and omitting VaR to define variables in JS

define variables in js, we use var, accustomed to omit the var can actually use.

, use var or omit var to define variable difference
1, var private variable, can only be used in the current js, or use in the current scope, define private variable, can not delete; 2. Var definition variables are omitted, such as a = “SSS”, which defines a global variable object a. Before a is deleted, we can directly input a in the browser console and then see the result.

is not recommended to omit var, when var is omitted to be careful
var will bring the following:

  1. semantic unclear.
  2. team development, easy to overwrite other scoped variables, throwing exceptions.
  3. add unnecessary members to the window object, which is unnecessary pollution brings to the window, so use the best delete off, by the way, lest affect other variable
    the original links: https://www.cnblogs.com/qijuzi/p/8329994.html

Read More: