当前位置:网站首页>Learning notes of JS variable scope and function
Learning notes of JS variable scope and function
2022-07-06 12:13:00 【Aboci Bang】
Scope of variable : Limit the available range of variables , It is divided into function scope and global scope .
Function scope :
Outside the function is the global scope – Variables can only be accessed inside functions ( The formal parameter of the function It's a local variable – It is equivalent to internally declaring the variable corresponding to the formal parameter ).
Global scope : Within the function is the function scope – Variables can be accessed under any scope .
~~ No keywords inside the function (var) What is declared is a global variable , But such a statement in strict mode is not standardized .
JS It's a functional programming language , A function is a code block used to complete a specific function , When a function has a return value, it can be used as the value of a variable , When there is no return value, it can be used as a tool to complete a business .
~~ When we feel that using variables to solve problems is too cumbersome and brain burning At this time, we should consider whether to draw a method To solve : “ I feel nothing wrong, but it makes you uncomfortable ” The situation of .
Function is a Function Object of type It has two Practical built-in properties :
(1) this
Pictured this In normal functions Pointing to window object , Global variables are also equivalent to window An attribute of an object
So in the function, we pass this You can also change the value of the global variable .
(2) arguments Express Formal parameter list information – Parameters and Corresponding value ( Class array object )
Learn with you
边栏推荐
- Time slice polling scheduling of RT thread threads
- JS object and event learning notes
- arduino JSON数据信息解析
- The dolphin scheduler remotely executes shell scripts through the expect command
- Oppo vooc fast charging circuit and protocol
- Navigator object (determine browser type)
- A possible cause and solution of "stuck" main thread of RT thread
- RuntimeError: cuDNN error: CUDNN_ STATUS_ NOT_ INITIALIZED
- C language, log print file name, function name, line number, date and time
- .elf .map .list .hex文件
猜你喜欢
Kaggle竞赛-Two Sigma Connect: Rental Listing Inquiries
Redis interview questions
共用体(union)详解【C语言】
Reno7 60W super flash charging architecture
Custom view puzzle getcolor r.color The color obtained by colorprimary is incorrect
E-commerce data analysis -- salary prediction (linear regression)
PyTorch四种常用优化器测试
数据分析之缺失值填充(重点讲解多重插值法Miceforest)
Working principle of genius telephone watch Z3
Fashion-Gen: The Generative Fashion Dataset and Challenge 论文解读&数据集介绍
随机推荐
Pytorch实现简单线性回归Demo
高通&MTK&麒麟 手机平台USB3.0方案对比
arduino获取数组的长度
数据分析之缺失值填充(重点讲解多重插值法Miceforest)
高通&MTK&麒麟 手機平臺USB3.0方案對比
JS 函数提升和var变量的声明提升
Kconfig Kbuild
I2C bus timing explanation
Redis 缓存更新策略,缓存穿透、雪崩、击穿问题
VSCode基础配置
Dead loop in FreeRTOS task function
Basic knowledge of lithium battery
Keyword inline (inline function) usage analysis [C language]
列表的使用
Custom view puzzle getcolor r.color The color obtained by colorprimary is incorrect
Pytoch implements simple linear regression demo
History object
GNN的第一个简单案例:Cora分类
【ESP32学习-1】Arduino ESP32开发环境搭建
Comparison of solutions of Qualcomm & MTK & Kirin mobile platform USB3.0