当前位置:网站首页>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
边栏推荐
猜你喜欢

Feature of sklearn_ extraction. text. CountVectorizer / TfidVectorizer

Cannot change version of project facet Dynamic Web Module to 2.3.

Characteristics, task status and startup of UCOS III

Pat 1097 duplication on a linked list (25 points)

OPPO VOOC快充电路和协议

Types de variables JS et transformations de type communes

RT-Thread 线程的时间片轮询调度

Arm pc=pc+8 is the most understandable explanation

Redis interview questions

E-commerce data analysis -- User Behavior Analysis
随机推荐
Reno7 60W超级闪充充电架构
. elf . map . list . Hex file
uCOS-III 的特点、任务状态、启动
inline详细讲解【C语言】
arduino获取随机数
ESP8266通过arduino IED连接巴法云(TCP创客云)
open-mmlab labelImg mmdetection
Machine learning -- linear regression (sklearn)
Dependency in dependencymanagement cannot be downloaded and red is reported
Inline detailed explanation [C language]
Detailed explanation of 5g working principle (explanation & illustration)
VSCode基础配置
ESP8266通过Arduino IDE连接Onenet云平台(MQTT)
Arduino JSON data information parsing
機器學習--線性回歸(sklearn)
Cannot change version of project facet Dynamic Web Module to 2.3.
【ESP32学习-1】Arduino ESP32开发环境搭建
C语言回调函数【C语言】
Characteristics, task status and startup of UCOS III
[golang] leetcode intermediate - fill in the next right node pointer of each node & the k-smallest element in the binary search tree