当前位置:网站首页>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边栏推荐
- UVa11991 Easy Problem from Rujia Liu
- Centos7 installing PHP
- Analysis of test questions in Chapter 13 of PMP preparation
- If you master these skills, you can also write a high score resume in the eyes of HR
- Deploy etcd cluster in static pod mode
- sklearn中随机森林RandomForestClassifier的参数含义
- How do testers plan for their future? To achieve 25K in 2 years?
- When will the index fail
- 可测性设计学习笔记
- QT知识:Qt Widgets小部件类【01】
猜你喜欢

Detailed explanation of search tree and hash table

Illustrator tutorial, how to recolor artwork in illustrator?

Successful transition from self-study test halfway, 10K for the first test

typeScript的定义类型:不能将类型“Timeout”分配给类型“number”;

Parameter meaning of random forest randomforestclassifier in sklearn

sklearn中随机森林RandomForestClassifier的参数含义
![[leetcode] small thinking of optimal division](/img/da/ea01225047158c9ca53ac1c585bcd9.jpg)
[leetcode] small thinking of optimal division

跳槽前恶补面试题,金三成功上岸腾讯,拿到30k的测开offer

Nexus3 build local warehouse

View 的事件分发机制
随机推荐
解决cvxpy报错The solver GLPK_MI is not installed
Centos7 installing MySQL 5.7
Fcpx tutorial, how to export video graphics and text in Final Cut Pro?
Lightroom 大使系列:用 Meg Loeks 捕捉怀旧之情
测试人如何规划自己的未来?才能实现入行2年达到25k?
Alipay payment Episode 12: Crazy God and Feige Alipay payment configuration code (free resources, no thanks for taking them away)
标量、向量、数组和矩阵
The required books for software testers (with e-books) recommended by senior Ali have benefited me a lot
How to determine the sample size of an inspection lot in SAP QM's initial sampling strategy?
Kyma application connectivity feature introduction
Typescript definition type: type 'timeout' cannot be assigned to type 'number';
登录mysql
MySQL field truncation principle and source code analysis
typeScript的定义类型:不能将类型“Timeout”分配给类型“number”;
To understand Devops, you must read these ten books!
Restful API 接口规范
P5076 [Fondation profonde 16. Exemple 7] Arbre binaire commun (version simplifiée)
做自媒体视频,友好的新媒体运营必备app分享
MySQL - the execution order of an SQL statement
DFT learning notes