当前位置:网站首页>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
边栏推荐
- Who says that PT online schema change does not lock the table, or deadlock
- ES6 grammar summary -- Part 2 (advanced part es6~es11)
- Kaggle competition two Sigma connect: rental listing inquiries
- AMBA、AHB、APB、AXI的理解
- Kaggle竞赛-Two Sigma Connect: Rental Listing Inquiries(XGBoost)
- I2C bus timing explanation
- Mysqldump error1066 error solution
- ESP learning problem record
- Mysql database interview questions
- GCC compilation options
猜你喜欢
随机推荐
STM32 如何定位导致发生 hard fault 的代码段
Arduino gets the length of the array
[template] KMP string matching
I2C bus timing explanation
Missing value filling in data analysis (focus on multiple interpolation method, miseforest)
imgcat使用心得
C语言回调函数【C语言】
Selective sorting and bubble sorting [C language]
ES6 grammar summary -- Part 2 (advanced part es6~es11)
Basic operations of databases and tables ----- modifying data tables
Priority inversion and deadlock
Esp8266 connects to onenet cloud platform (mqtt) through Arduino IDE
Page performance optimization of video scene
RT-Thread 线程的时间片轮询调度
ES6语法总结--下篇(进阶篇 ES6~ES11)
列表的使用
Stm32f1+bc20+mqtt+freertos system is connected to Alibaba cloud to transmit temperature and humidity and control LED lights
R & D thinking 01 ----- classic of embedded intelligent product development process
Esp8266 uses Arduino to connect Alibaba cloud Internet of things
Working principle of genius telephone watch Z3