当前位置:网站首页>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
边栏推荐
- How do indexes match?
- Golden, silver and four job hopping season, teach you these tips to improve the interview success rate
- HR SaaS unicorn is about to emerge. Will the employee experience be the next explosive point?
- Bsn-ddc basic network introduction, technical features, unique advantages, application scenarios and platform access
- What does MySQL full value match mean
- Halcon angle and radian interchange
- When will the index fail
- CentOS7安装MySQL5.7操作说明
- [tutorial] detailed explanation of the page rules parameter settings of cloudflare CDN
- Social metauniverse: start from redefining yourself
猜你喜欢
[leetcode 7 solution] integer inversion
Scala基础语法入门(三)Scala中的各种运算符
2022年春招,测试工程师全套面试攻略,一篇吃透全部技术栈(全是干货)
House raiding 3
Illustrator tutorial, how to recolor artwork in illustrator?
Wall Street cheat sheet
EditText控制从左上角开始
【生成对抗网络学习 其三】BiGAN论文阅读笔记及其原理理解
Generate API documents using swagger (go language example)
A simple understanding of consistent hash
随机推荐
入行5年从10k的功能测试到年薪40w的测试开发,花7天时间整理的超全学习路线
Bsn-ddc basic network introduction, technical features, unique advantages, application scenarios and platform access
标量、向量、数组和矩阵
Why can't fields with high duplicate values be indexed (such as gender fields)
Design rule check constraint (set_max_transition, set_max_capability)
【生成对抗网络学习 其三】BiGAN论文阅读笔记及其原理理解
Introduction to the characteristics of building a balancer decentralized exchange market capitalization robot
Generate API documents using swagger (go language example)
What is the difference between union and union all
What is an index?
Login to MySQL
Transaction code qs28 of SAP QM preliminary level
I learned database at station B (10): View
EDI 855 purchase order confirmation
循环插入excel某一列,以及多列之和
EditText控制从左上角开始
View 的事件分发机制
QT knowledge: QT widgets widget class [01]
MySQL field truncation principle and source code analysis
Detect current system language