当前位置:网站首页>JS scope and scope chain
JS scope and scope chain
2022-07-25 20:13:00 【InfoQ】
Scope
Local scope
Generally, it can be accessed only in fixed code fragments
function add(){
var name = " test "
console.log(name)
}
add()
// console.log(name) name is not defined
Global scope
var name = " external "
function add(){
var name = " test "
console.log(name)
}
add()
console.log(name)
Scope chain
var name = "Out"
function out(){
var inOut = "In";
function inTao(){
console.log("inTao---------------"+inOut)
//undefined , Why would it be undefinded Well ,
// Because it will first find out whether there is a inOut, If there is , also inOut State in advance , Then the value will be displayed correctly ; Otherwise, it will show undefinded, Because it only knows that there is one in the current environment inOut
var ss = name;
var inOut = ss;
console.log(" After the assignment ss-----------"+ss) //Out
console.log("inTao The modified inOut-----------"+inOut) // Out
}
inTao()
}
console.log(" External name---------------"+name) // Out
out()
- Summary of relevant knowledge of scope chain :
The scope chain always follows Look from the inside out layer by layer
Own variable object -----> Variable external () Variable object of local environment -----> Variable object of global environment .
边栏推荐
- Proxy implements MySQL read / write separation
- UNET and mask RCNN
- PyTorch 模型 onnx 文件的导出和调用
- 【高等数学】【5】定积分及应用
- QQ是32位还是64位软件(在哪看电脑是32位还是64位)
- The use of new promise, async and await in the project, and the practical application of promise.all in the project
- Recommended system topic | Minet: cross domain CTR prediction
- DIY个人服务器(diy存储服务器)
- 分享 25 个有用的 JS 单行代码
- Web crawler principle analysis "suggestions collection"
猜你喜欢

当AI邂逅生命健康,华为云为他们搭建三座桥
![[today in history] July 15: Mozilla foundation was officially established; The first operation of Enigma cipher machine; Nintendo launches FC game console](/img/7d/7a01c8c6923077d6c201bf1ae02c8c.png)
[today in history] July 15: Mozilla foundation was officially established; The first operation of Enigma cipher machine; Nintendo launches FC game console

"Share" devaxpress asp Net v22.1 latest version system environment configuration requirements

【高等数学】【3】微分中值定理与导数的应用

During the interview, I was asked how to remove the weight of MySQL, and who else wouldn't?

Prescan quick start to master the special functions of prescan track editing in lecture 18

Introduction and construction of consul Registration Center
![[today in history] July 3: ergonomic standards act; The birth of pioneers in the field of consumer electronics; Ubisoft releases uplay](/img/18/b06e2e5a2f76dc2da1c2374b8424b3.png)
[today in history] July 3: ergonomic standards act; The birth of pioneers in the field of consumer electronics; Ubisoft releases uplay

Google pixel 6A off screen fingerprint scanner has major security vulnerabilities

Software designer afternoon real topic: 2009-2022
随机推荐
[today in history] June 29: SGI and MIPS merged; Microsoft acquires PowerPoint developer; News corporation sells MySpace
FormatDateTime说解[通俗易懂]
03-树1 树的同构
数字信息化(先枚举假设,再看是否满足条件)(1089 狼人杀-简单版)
RF, gbdt, xgboost feature selection methods "recommended collection"
当AI邂逅生命健康,华为云为他们搭建三座桥
10.< tag-动态规划和子序列, 子数组>lt.53. 最大子数组和 + lt.392. 判断子序列 dbc
QML combines qsqltablemodel to dynamically load data MVC "recommended collection"
What is the method to load the torch pre trained model for the mindspore model finetune?
Pytorch's transforms (numpy data type is converted to tensor, normalized and resized)
DIY个人服务器(diy存储服务器)
Successfully solved typeerror: a bytes like object is required, not 'str‘
Rainbond插件扩展:基于Mysql-Exporter监控Mysql
RepVGG网络中重参化网络结构解读【附代码】
[Infographics Show] 248 Public Domain Name
[advanced mathematics] [3] Application of differential mean value theorem and derivative
wallys//IPQ5018/IPQ6010/PD-60 802.3AT Input Output 10/100/1000M
Arrow 之 Parquet
Array of sword finger offer question bank summary (I) (C language version)
CarSim仿真快速入门(十六)—CarSim传感器仿真之ADAS Sensor Objects (2)
