当前位置:网站首页>js变量提升(hoisting)
js变量提升(hoisting)
2022-07-01 09:14:00 【su27_0101】
变量提升 又叫变量声明 提升到 当前所在作用域 最前面
如:
var a = 5;
function fn(){
a; // undefined
var a = 6;
a; // 6
}
fn();
为何 函数 内 第一个 a = undefined
我们可以借用变量提升的规则转写为
function fn(){
var a = undefined;
a; // undefined
a = 6;
a; // 6
}
这样是否就十分清晰 js 会将 函数或变量声明 默认提升到当前作用域最前面,而以上例子当前的作用域为函数fn
边栏推荐
- Bird recognition app
- dsPIC30F6014a LCD 方块显示
- Shell script echo command escape character
- Flink interview questions
- 【pytorch】transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
- How to launch circle of friends marketing and wechat group activities
- Redis——Lettuce连接redis集群
- It technology ebook collection
- Flink面试题
- TV size and viewing distance
猜你喜欢
Reproduced Xray - cve-2017-7921 (unauthorized access by Hikvision)
Imitation of Baidu search results top navigation bar effect
Principles of Microcomputer - internal and external structure of microprocessor
Performance improvement 2-3 times! The second generation Kunlun core server of Baidu AI Cloud was launched
Ape anthropology topic 20 (the topic will be updated from time to time)
小鸟识别APP
Why is the Ltd independent station a Web3.0 website!
【电赛训练】红外光通信装置 2013年电赛真题
NiO zero copy
nacos服务配置和持久化配置
随机推荐
如何高效拉齐团队认知
[interview brush 101] linked list
记一次redis超时
类加载
【pytorch】nn. AdaptiveMaxPool2d
Shell script -for loop and for int loop
How to launch circle of friends marketing and wechat group activities
Structure de l'arbre - - - arbre binaire 2 traversée non récursive
Simple load balancing with Nacos
Ranking list of domestic databases in February, 2022: oceanbase regained the "three consecutive increases", and gaussdb is expected to achieve the largest increase this month
Common interview questions for embedded engineers 2-mcu_ STM32
JCL and slf4j
美团2022年机试
【pytorch】nn.CrossEntropyLoss() 与 nn.NLLLoss()
Class loading
[ESP nanny level tutorial preview] crazy node JS server - Case: esp8266 + DHT11 +nodejs local service + MySQL database
SDN_简单总结
【pytorch】softmax函数
MapReduce编程基础
Learning practice: comprehensive application of cycle and branch structure (II)