当前位置:网站首页>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
边栏推荐
- ESP学习问题记录
- 1081 rational sum (20 points) points add up to total points
- Gallery's image browsing and component learning
- Pytorch four commonly used optimizer tests
- RT thread API reference manual
- ESP8266通过arduino IED连接巴法云(TCP创客云)
- Variable parameter principle of C language function: VA_ start、va_ Arg and VA_ end
- Kaggle competition two Sigma connect: rental listing inquiries
- Redis interview questions
- Working principle of genius telephone watch Z3
猜你喜欢
Comparison of solutions of Qualcomm & MTK & Kirin mobile platform USB3.0
ES6 grammar summary -- Part I (basic)
AMBA、AHB、APB、AXI的理解
arduino JSON数据信息解析
共用体(union)详解【C语言】
[template] KMP string matching
VSCode基础配置
Working principle of genius telephone watch Z3
Arduino JSON data information parsing
JS variable types and common type conversions
随机推荐
open-mmlab labelImg mmdetection
A possible cause and solution of "stuck" main thread of RT thread
VSCode基础配置
Gallery's image browsing and component learning
ESP8266通过arduino IED连接巴法云(TCP创客云)
RT-Thread 线程的时间片轮询调度
JS 函数提升和var变量的声明提升
Arduino get random number
优先级反转与死锁
Understanding of AMBA, AHB, APB and Axi
Analysis of charging architecture of glory magic 3pro
The dolphin scheduler remotely executes shell scripts through the expect command
ES6 grammar summary -- Part I (basic)
imgcat使用心得
Symbolic representation of functions in deep learning papers
物联网系统框架学习
关键字 inline (内联函数)用法解析【C语言】
FreeRTOS 任务函数里面的死循环
Apprentissage automatique - - régression linéaire (sklearn)
Detailed explanation of Union [C language]