当前位置:网站首页>Three ways and differences of defining functions in JS
Three ways and differences of defining functions in JS
2022-06-30 14:28:00 【Bamboo shrimp】
1、 Function declaration ( priority of use , It will be promoted when it is declared )
function fun(){
console.log('123');
}
fun()// Call the function name directly
2、 Function expression , Also called anonymous function ;
var fun = function(){
console.log('123');
}
fun()// Call anonymous functions , Use variable names plus ()
The process : This is defined by assigning a function to a variable , Function has no real name ; Since it's a variable , When making a statement , The function itself is not promoted , What is promoted is the variable name ;
3、 Self executing functions ( Do it yourself , And call yourself at the same time of declaration , It can only be called once )
(function()(
console.log('123')
})();
// principle : Evolved from a functional expression
The process : stay 2 in , hold fun(), Medium fun Directly replace with the function body , became function(){}(); Plus () Enclosed function body , lest js False positives are function declarations
边栏推荐
- 【科研数据处理】[基础]类别变量频数分析图表、数值变量分布图表与正态性检验(包含对数正态)
- PHP reverses scenarios based on code and skillfully uses debug_ backtrace()
- I want to ask how to open an account at China Merchants Securities? Is it safe to open a stock account through the link
- Begin End use the pit encountered
- Detailed explanation of the first three passes of upload Labs
- Using docker to manage MySQL services under Windows
- ot initialized – call ‘refresh’ before invoking lifecycle methods via the context: Root WebApplicati
- Uniapp upload image method
- Introduction to the renewal of substrate source code: the pallet alliance is incorporated into the main line,
- "As a service", the inevitable choice of enterprise digital transformation
猜你喜欢

Mysql database foundation: stored procedures and functions

Google Earth engine (GEE) -- converts string to number and applies it to time search (ee.date.fromymd)

Initial attack and defense world Misc

QQ was stolen? The reason is

用Unity实现Flat Shading
![[scientific research data processing] [practice] frequency analysis chart of category variables, distribution chart of numerical variables and normality test (including lognormal)](/img/5a/eaa845f4332f0b8ee8b6409d6a79e8.png)
[scientific research data processing] [practice] frequency analysis chart of category variables, distribution chart of numerical variables and normality test (including lognormal)
![[buuctf] [actf2020 freshman competition]include](/img/42/50439290177fdea5f431e315cac1a1.jpg)
[buuctf] [actf2020 freshman competition]include

Laravel configures passport and returns token using JWT

Race of golang

“即服务”,企业数字化转型的必然选择
随机推荐
Laravel upload error
DB2 SQL Error: SQLCODE=-206, SQLSTATE=42703
Deep understanding Net (2) kernel mode 3 Kernel mode construct mutex
Project management - common English vocabulary I
想請教一下,我在佛山,到哪裏開戶比較好?手機開戶是安全麼?
[observation] as the intelligent industry accelerates, why should AI computing power take the lead?
Pytoch viewing model parameter quantity and calculation quantity
“即服务”,企业数字化转型的必然选择
On simple code crawling Youdao translation_ 0's problem (to be solved)
Introduction to reverse commissioning - VA and RVA conversion in PE 04/07
[redis series] redis learning 16. Redis Dictionary (map) and its core coding structure
Dart extended feature
I'd like to ask you, where can I open an account in Foshan? Is it safe to open a mobile account?
PHP excel export function encapsulation (based on phpexcel class)
MFQE 2.0: A New Approach for Multi-FrameQuality Enhancement on Compressed Video
Cost forecast of PMP (BAC, EAC, etc)
V3 03_ Getting started
【BUUCTF】 EasySql
Rpm2rpm packaging steps
@component使用案例