当前位置:网站首页>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
边栏推荐
- AMBA、AHB、APB、AXI的理解
- imgcat使用心得
- 物联网系统框架学习
- 高通&MTK&麒麟 手機平臺USB3.0方案對比
- Kconfig Kbuild
- Pytoch temperature prediction
- JS variable types and common type conversions
- RuntimeError: cuDNN error: CUDNN_ STATUS_ NOT_ INITIALIZED
- Page performance optimization of video scene
- 1081 rational sum (20 points) points add up to total points
猜你喜欢

ES6 grammar summary -- Part I (basic)

Basic operations of databases and tables ----- creating data tables

Working principle of genius telephone watch Z3

A possible cause and solution of "stuck" main thread of RT thread

Analysis of charging architecture of glory magic 3pro

Arduino JSON data information parsing

Redis 缓存更新策略,缓存穿透、雪崩、击穿问题

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

open-mmlab labelImg mmdetection

uCOS-III 的特点、任务状态、启动
随机推荐
Mysql database interview questions
Arm pc=pc+8 is the most understandable explanation
arduino获取数组的长度
小天才电话手表 Z3工作原理
JS数组常用方法的分类、理解和运用
OPPO VOOC快充电路和协议
STM32 如何定位导致发生 hard fault 的代码段
Fashion-Gen: The Generative Fashion Dataset and Challenge 论文解读&数据集介绍
Machine learning -- linear regression (sklearn)
基于Redis的分布式锁 以及 超详细的改进思路
Kaggle竞赛-Two Sigma Connect: Rental Listing Inquiries(XGBoost)
Oppo vooc fast charging circuit and protocol
OSPF message details - LSA overview
RT-Thread 线程的时间片轮询调度
Variable parameter principle of C language function: VA_ start、va_ Arg and VA_ end
ESP学习问题记录
Selective sorting and bubble sorting [C language]
STM32 how to locate the code segment that causes hard fault
Who says that PT online schema change does not lock the table, or deadlock
Dead loop in FreeRTOS task function