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:
- semantic unclear.
- team development, easy to overwrite other scoped variables, throwing exceptions. li>
- 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 li> ol>
Read More:
- How to read JS file app.ux Global variables in
- When installing software in Ubuntu, it prompts: E: You don’t have enough free space in /var/cache/apt/archives/.
- Command “python setup.py egg_info” failed with error code 1 in /private/var/folders/14/4hz051qx0wqd3
- An error occurred trying to connect: get http: / / var / run/ docker.sock/v1 .21/containers/json?all
- Plug in loaded: fastmirror, langpacks / var / run/ yum.pid Locked, another program with PID 2323 is running
- dpkg: error processing archive /var/cache/apt/archives/libc6-dev-amd64_2.19-0ubuntu6.9_i386.deb (–u
- flAbsPath on /var/lib/dpkg/status failed – realpath
- Error: enoent: no such file or directory, stat ‘/ usr / local / var / www / / book/gitbook/git
- Error: enoent: no such file or directory, stat ‘/ usr / local / var / www / /_ book/gitbook/git
- nginx: [error] invalid PID number in /var/run/nginx.pid
- ERROR: While executing gem … (Errno::EACCES) Permission denied @ dir_s_mkdir – /var/lib/gems
- Ubuntu error: flAbsPath on /var/lib/dpkg/status failed – realpath (2: No such file or directory)
- /var/run/nginx/nginx.pid” failed (2: No such file or directory)
- nginx: open() “/var/run/nginx.pid“ failed (2: No such file or directory)
- php open(/var/lib/php/session/sess_4ofxxx, O_RDWR) failed: Permission denied (13)
- nginx: [error] open() “/usr/local/var/run/nginx.pid” failed (2: No such file or directory)
- [Sovled] Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
- Solve the problem of copy failed: stat / var / lib / docker / TMP / docker builder 455335933 / opt: no such file or directory
- nginx: [error] open() "/var/run/nginx/nginx.pid" failed (2: No such file or directory)
- After vscode installs ts, TSC compiles and generates JS, and an error is reported (repeated variables, etc.)