当前位置:网站首页>Understanding of functions
Understanding of functions
2022-06-12 20:34:00 【Stand on the bridge and bake cold noodles】
What is a function ?
A program structure that holds a piece of reusable code
Several ways to define functions :
- Use function Declaration method , The declaration will be advanced . principle :JS Before the engine starts executing , Will scan and use first var Declaration and use function Declared variable name and function name , These two names will be declared in advance , But the assignment remains in place , Will disrupt the normal execution of the program
- Use the method of assignment var Function name =function(){} benefits : Will not be declared ahead of time , It ensures the original execution sequence of the program
- use new The way ( Almost no use ). Exposes the nature of functions , Every function The bottom layer is equivalent to new Function, Each function has its own unique memory address , Even two identical functions , The comparison also returns false
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
console.log(a);//undefined
var a=10;
console.log(a);//10
// function fun(){console.log(1)}
// fun();//2
// function fun(){console.log(2)}
// fun();//2
var fun=function(){
console.log(1)
}
fun();
var fun=function(){
console.log(2)
}
fun();
</script>
</body>
</html>
Running results :
undefined
10
1
2边栏推荐
- HR SaaS unicorn is about to emerge. Will the employee experience be the next explosive point?
- Detect current system language
- 检测当前系统语言
- Zhangqiming, vice director of the United Front Work Department of the CPC Anhui Provincial Committee, led a team to investigate the HoloNet Royal Hefei R & D base
- What does SQL replace or
- Nexus3搭建本地仓库
- 函数的了解
- 没有学历,自学软件测试,找到一份月入过万的测试工作真的有可能吗?
- 半路自学测试成功转行,第一份测试工作就拿10k
- QT知识:Qt Widgets小部件类【01】
猜你喜欢

Lightroom 大使系列:用 Meg Loeks 捕捉怀旧之情

Lightroom Ambassador series: capturing nostalgia with MEG loeks

If you master these skills, you can also write a high score resume in the eyes of HR

EditText control starts from the upper left corner

Index optimization principle

In 2022, FISCO bcos MVP recognized that the channel was open and invited you to become an open source leader

Is it really possible to find a testing job with a monthly income of more than 10000 without a degree and self-study software testing?

Centos7 installing PHP

牛客网:三数之和

同时做测试,别人已经年薪20w起,为什么你还在为达到月薪10k而努力?
随机推荐
解决cvxpy报错The solver GLPK_MI is not installed
Illustrator tutorial, how to recolor artwork in illustrator?
HR SaaS unicorn is about to emerge. Will the employee experience be the next explosive point?
CentOS7安装MySQL5.7操作说明
牛客網:三數之和
How mysterious is "PIP not an internal or external command, nor a runnable program or batch file"
Restful API interface specification
2022年春招,测试工程师全套面试攻略,一篇吃透全部技术栈(全是干货)
一致性哈希的简单认识
Transaction code qs28 of SAP QM preliminary level
Is it really possible to find a testing job with a monthly income of more than 10000 without a degree and self-study software testing?
What is a hash index?
P5076 [Fondation profonde 16. Exemple 7] Arbre binaire commun (version simplifiée)
跳槽前恶补面试题,金三成功上岸腾讯,拿到30k的测开offer
Golang type assertion understanding [go language Bible]
MySQL installation and Application
牛客网:三数之和
Fcpx tutorial, how to export video graphics and text in Final Cut Pro?
Lightroom 大使系列:用 Meg Loeks 捕捉怀旧之情
设计规则检查约束(set_max_transition、set_max_capacitance)