当前位置:网站首页>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
边栏推荐
- C language callback function [C language]
- arduino JSON数据信息解析
- E-commerce data analysis -- User Behavior Analysis
- Custom view puzzle getcolor r.color The color obtained by colorprimary is incorrect
- Raspberry pie tap switch button to use
- RT-Thread 线程的时间片轮询调度
- 电商数据分析--用户行为分析
- 機器學習--線性回歸(sklearn)
- Arduino uno R3 register writing method (1) -- pin level state change
- PyTorch四种常用优化器测试
猜你喜欢

Reno7 60W超级闪充充电架构

Analysis of charging architecture of glory magic 3pro

The dolphin scheduler remotely executes shell scripts through the expect command

level16

JS變量類型以及常用類型轉換

ESP8266使用arduino连接阿里云物联网

机器学习--决策树(sklearn)

RT-Thread API参考手册

R & D thinking 01 ----- classic of embedded intelligent product development process

MP3mini播放模块arduino<DFRobotDFPlayerMini.h>函数详解
随机推荐
程序员老鸟都会搞错的问题 C语言基础 指针和数组
IOT system framework learning
STM32 how to locate the code segment that causes hard fault
Arm pc=pc+8 is the most understandable explanation
Navigator object (determine browser type)
基于Redis的分布式ID生成器
Mysqldump error1066 error solution
Basic operations of databases and tables ----- classification of data
Oppo vooc fast charging circuit and protocol
C语言回调函数【C语言】
sklearn之feature_extraction.text.CountVectorizer / TfidVectorizer
I2C bus timing explanation
JS数组常用方法的分类、理解和运用
Symbolic representation of functions in deep learning papers
uCOS-III 的特点、任务状态、启动
PyTorch四种常用优化器测试
Detailed explanation of Union [C language]
Gallery's image browsing and component learning
ESP8266使用arduino连接阿里云物联网
RT thread API reference manual