当前位置:网站首页>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
边栏推荐
- Heavyweight: the domestic ide was released, developed by Alibaba, and is completely open source!
- Lfi-rce without controllable documents
- Crypto questions
- The first three passes of sqli Labs
- ThinkPHP show method parameter controllable command execution
- JMeter transaction controller
- XSS challenge (1-5) more detailed answers
- 深入理解.Net中的线程同步之构造模式(二)内核模式4.内核模式构造物的总结
- V3 03_ Getting started
- PHP generate images into Base64
猜你喜欢

重磅:国产IDE发布,由阿里研发,完全开源!
![[buuctf] [actf2020 freshman competition]include](/img/42/50439290177fdea5f431e315cac1a1.jpg)
[buuctf] [actf2020 freshman competition]include

Realize a simple LAN communication (similar to feiqiu)

Tencent two sides: @bean and @component are used on the same class. What happens?

Att & CK red team evaluation field (I)

Problems in QT creator (additional unknown and error lines are listed in the debug output window)

Shell programming overview

Deep understanding Net (2) kernel mode 4 Summary of kernel pattern constructs

Fastcgi CGI shallow understanding

Notes on reverse learning in the first week of winter vacation
随机推荐
Calculates the length of the last word in a string, separated by spaces
Jetpack compose for perfect screen fit
DiceCTF - knock-knock
Go common lock mutex and rwmutex
org. json. The jsonobject object is converted to JSON, and JSON adds new elements. The value is obtained according to the JSON key. And list object format string to jsonarray
Numpy creates an empty array data = np empty(shape=[1, 64,64,3])
[scientific research data processing] [basic] category variable frequency analysis chart, numerical variable distribution chart and normality test (including lognormal)
Configuration of headquarters dual computer hot standby and branch infrastructure for firewall Foundation
Introduction to the construction and development of composer private warehouse
JMeter transaction controller
Three uses of golang underscores
Thinkphp5 log file contains trick
The programming competition is coming! B station surrounding, senior members and other good gifts to you!
Upgrade composer self update
Shell programming overview
[buuctf] [actf2020 freshman competition]exec1
Project management - common English vocabulary I
The first dark spring cup dnuictf
Crypto questions
[kubernetes series] k8s set mysql8 case insensitive