当前位置:网站首页>The difference between VaR and let_ The difference between let and VaR
The difference between VaR and let_ The difference between let and VaR
2022-06-11 20:45:00 【Tianma 3798】
js Define variable foreword
1.js Defining variables Use var perhaps let
2.js Define constants Use const
3.var Variables are defined using js Language is born ; let Define variables from ES6 New syntax started .
4.let Defining variables , It conforms to the logic of variables defined by conventional strongly typed languages , The new definition can be used again + Can not repeat life .
var and let The difference between _let and var The differences are sorted out as follows :
One 、 Different scope levels
var yes Function level scope
let Can only be Block level scope , Follow C# The scope of variables of equal strong type is the same .
Declared in the function var, The whole function is valid , For example, in for A defined in a loop var Variable , In fact, it is for It's also accessible outside the loop .
and let Because it's a block scope , So if the variable defined in the block scope , For example, in for Within the loop , It is not accessible outside , therefore for Circulation is recommended let.
code snippet :
//for Cyclic {} It's a block level scope
for (var i = 0; i < 10; i++) { }
console.info(i); // Print :10
for (let j = 0; j < 10; j++) { }
console.info(j); //j is not defin边栏推荐
- Calculation of Zeno paradox
- 产品资讯|PoE网卡家族集体亮相,机器视觉完美搭档!
- Weekly 02 | pour être honnête, je suis un étudiant du MIT
- [index system] the latest modeling method of data warehouse index system
- Implement AOP and interface caching on WPF client
- Recompile kubeadm to solve the problem of certificate expiration in one year
- Pyqt5 technical part - cause of the problem that setting the top of the window does not take effect. Setwindowflags() does not take effect after setting the parameters. Solution
- php pcntl_fork 创建多个子进程解析
- Docker installation redis
- [Monday commuter radio station] cron expression. It's enough to read this article
猜你喜欢

10 R vector operation construction

Windows icon display exception resolution. The desktop icon is abnormal, the start menu icon is abnormal, and the taskbar icon is abnormal. Icon cache location.

模拟Oracle锁等待与手工解锁

【数据可视化】Apache Superset 1.2.0教程 (三)—— 图表功能详解

频域滤波器

Final examination of Dialectics of nature 1

周刊02|不瞒你说,我其实是MIT的学生

moderlarts第一次培訓

UDP、TCP

Modelarts second job
随机推荐
Volcano engine, Alibaba cloud and Tencent cloud jointly released the 'ultra low delay' live broadcast technical standard
php pcntl_fork 创建多个子进程解析
机器视觉工控机PoE图像采集卡应用解析
Final examination of theory and practice of socialism with Chinese characteristics 1
Oracle case: ora-00600: internal error code, arguments: [4187]
模拟Oracle锁等待与手工解锁
15 r exercise
26. 定时器
14 r basic exercises
7905 和TL431 负电压稳压电路 - 相对于电源正极的稳压和浮地电路
全球机器视觉市场规模持续上涨,PoE图像采集卡为工业相机提供高速传输通道
Redis第四话 -- redis高性能原理(多路复用)和高可用分析(备份、主从)
Object storage of CEPH distributed storage
Current situation and future development trend of global and Chinese cogeneration system market from 2022 to 2028
10 R vector operation construction
unity package manager starting server stuck(Unity啟動卡在starting server,然後報錯)
28. JS执行机制
moderlarts第二次作业
Title does not display after toolbar replaces actionbar
Pyqt5 technical part - cause of the problem that setting the top of the window does not take effect. Setwindowflags() does not take effect after setting the parameters. Solution