当前位置:网站首页>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
边栏推荐
- Shell script - array definition and getting array elements
- 【pytorch】2.4 卷积函数 nn.conv2d
- [ESP nanny level tutorial preview] crazy node JS server - Case: esp8266 + MQ Series + nodejs local service + MySQL storage
- Shell script -for loop and for int loop
- nacos简易实现负载均衡
- Leetcode daily question brushing record --540 A single element in an ordered array
- Naoqi robot summary 28
- TV size and viewing distance
- Learning practice: comprehensive application of cycle and branch structure (II)
- Daily office consumables management solution
猜你喜欢

【检测技术课案】简易数显电子秤的设计与制作

Redis -- lattice connects to redis cluster

nacos简易实现负载均衡
![[pytorch] 2.4 convolution function nn conv2d](/img/eb/382a00af5f88d5954f10ea76343d6e.png)
[pytorch] 2.4 convolution function nn conv2d

Design and manufacture of simple digital display electronic scale

Learning practice: comprehensive application of cycle and branch structure (II)

Vsync+ triple cache mechanism +choreographer

安装Oracle EE

Principle and application of single chip microcomputer timer, serial communication and interrupt system

小鸟识别APP
随机推荐
【pytorch】transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))
2.2 【pytorch】torchvision. transforms
How to effectively align team cognition
pcl_viewer命令
Leetcode daily question brushing record --540 A single element in an ordered array
[ESP nanny level tutorial] crazy completion chapter - Case: chemical environment system detection based on Alibaba cloud and Arduino, supporting nail robot alarm
Mysql8.0 learning record 17 -create table
树结构---二叉树2非递归遍历
Flink interview questions
【ESP 保姆级教程】疯狂毕设篇 —— 案例:基于物联网的GY906红外测温门禁刷卡系统
记一次redis超时
【pytorch】nn.CrossEntropyLoss() 与 nn.NLLLoss()
2.3 [kaggle dataset - dog feed example] data preprocessing, rewriting dataset, dataloader reading data
TV size and viewing distance
序列化、监听、自定义注解
Common interview questions for embedded engineers 2-mcu_ STM32
Naoqi robot summary 28
Log4j log framework
Principles of Microcomputer - Introduction
Jeecg restart alarm 40001