当前位置:网站首页>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
边栏推荐
- 机器学习--决策树(sklearn)
- Variable star user module
- Dependency in dependencymanagement cannot be downloaded and red is reported
- Dead loop in FreeRTOS task function
- Machine learning -- linear regression (sklearn)
- VIM command line notes
- Oppo vooc fast charging circuit and protocol
- Machine learning -- decision tree (sklearn)
- STM32 how to locate the code segment that causes hard fault
- RT-Thread的main线程“卡死”的一种可能原因及解决方案
猜你喜欢
I2C bus timing explanation
Understanding of AMBA, AHB, APB and Axi
Machine learning -- decision tree (sklearn)
【ESP32学习-2】esp32地址映射
ARM PC=PC+8 最便于理解的阐述
Apprentissage automatique - - régression linéaire (sklearn)
RT-Thread API参考手册
Arduino uno R3 register writing method (1) -- pin level state change
IOT system framework learning
Arm pc=pc+8 is the most understandable explanation
随机推荐
[golang] leetcode intermediate - fill in the next right node pointer of each node & the k-smallest element in the binary search tree
Dead loop in FreeRTOS task function
Characteristics, task status and startup of UCOS III
arduino UNO R3的寄存器写法(1)-----引脚电平状态变化
高通&MTK&麒麟 手機平臺USB3.0方案對比
FreeRTOS 任务函数里面的死循环
C language callback function [C language]
inline详细讲解【C语言】
Basic use of pytest
[Red Treasure Book Notes simplified version] Chapter 12 BOM
[esp32 learning-1] construction of Arduino esp32 development environment
AMBA、AHB、APB、AXI的理解
Analysis of charging architecture of glory magic 3pro
Kaggle competition two Sigma connect: rental listing inquiries
Basic operations of databases and tables ----- classification of data
[template] KMP string matching
Arm pc=pc+8 is the most understandable explanation
Rough analysis of map file
ES6语法总结--下篇(进阶篇 ES6~ES11)
There are three iPhone se 2022 models in the Eurasian Economic Commission database