当前位置:网站首页>Pre parsing, recursive functions and events in day25 JS 2021.09.16
Pre parsing, recursive functions and events in day25 JS 2021.09.16
2022-06-28 11:30:00 【Little dream of becoming a big man】
Pre parse :( Variable Promotion )
The code is parsed before execution , Put the names of variables and functions at the top of the current scope .
summary :
1. use var Variable of keyword name , Promote the variable name to the front of the current scope , Assignment does not raise
2. The customized function is promoted to the front of the current scope as a whole
3. The function has the same name , The back one will cover the front one
4. Variables and functions have the same name , Function first
Interview questions :
//1.
var num = 10;
fn1();
function fn1() {
console.log(num);
var num = 20;
}
//2.
var a = 18;
fn2();
function fn2() {
var b = 9;
console.log(a);
console.log(b);
}
//3.
fn3();
console.log(c);
console.log(b);
console.log(a);
function fn3() {
var a = b = c = 9;
console.log(a);
console.log(b);
console.log(c);
}
//4. Thinking questions
var a = 4;
console.log(a);
a = 6;
console.log(a);
function a() {
console.log(' Ha ');
}
a();
a = 10;
console.log(a);
Nesting of functions :( Calling function in function )
Scope :
1. Variables outside a function are called global variables , It can be used outside and inside functions .
2. Variables inside a function are called local variables , Can only be used inside a function .
Variable access and assignment : Will find... In the current scope , If not, they will go to their superiors Until the overall situation is found
visit : If there is nothing in the overall situation You're going to report a mistake It will also show undefiend
assignment : If not in the overall situation You will define a variable by yourself And assign
Recursive function :( Is to call yourself in a function ) Cause memory consumption Poor performance
// seek 10 Order sum of , namely :10+9+8+...+1
function facSum(num){
if(num == 1){
return 1;
}
return num + facSum(num-1);
}
var res = facSum(10);
console.log(res); // 55
event :( The user's actions on the web page , for example : Mouse click 、 Mouse movement 、 Press the keyboard )
-1) Through the binding structure Trigger the function to execute the call The name of the binding . Event name = function(){}
- 2) Through the binding structure Trigger the function to execute the call The name of the binding . Event name = The name of the function The parentheses that follow the execution cannot have
Mouse events :
- onclick Click events
- ondblclick double-click
- onmousemove Mouse migration
- onmouseout Mouse removal There is a change when the mouse moves in and out When removed once, it will change once
- onmousedown The mouse click
- onmouseup The mouse is raised
- oncontextmenu Right click
Keyboard events : The binding object is window
- onkeydown Press the keyboard
- onkeyup Keyboard up
- onkeypress Keyboard tapping Binding key
Form events : verification
- onfocus focusing
- onblur Lose focus
- onchange change
边栏推荐
- Scientific research - web of science retrieval skills
- 拼接String集合中的字符串_基于Stream
- day28 严格模式、字符串 js 2021.09.22
- 2022 open source software security status report: over 41% of enterprises do not have enough confidence in open source security
- 基于验证码识别的机器学习项目captcha_trainer操作实践
- day37 js笔记 运动函数 2021.10.11
- js中的数组方法 2021.09.18
- Adding a new user in MySQL 5.7
- 网页提示此站点不安全解决方案
- Get current system date
猜你喜欢
Jetpack Compose Desktop 桌面版本的打包和发布应用
JS foundation 1-js introduction and operator
太阳能无线LED显示屏的特点
This Exception was thrown from a job compiled with Burst, which has limited exception support. 报错
JS foundation 3
day34 js笔记 正则表达式 2021.09.29
For example, the visual appeal of the live broadcast of NBA Finals can be seen like this?
一套十万级TPS的IM综合消息系统的架构实践与思考
Training notice | special training notice on epidemic prevention and security prevention for overseas Chinese funded enterprises, institutions and personnel in 2022
静态库的制作和使用
随机推荐
携手Cigent:群联为SSD主控固件引入高级网络安全防护特性
day29 js笔记 2021.09.23
[sciter]:sciter如何使用i18实现桌面应用多语言切换及其利弊
Graduated
windows 10下载安装mysql5.7
将浏览器中的文件 url转换为File流
[sciter]: use of sciter FS module scanning file API and its details
获取系统当前日期
Makefile简介
Thesis reading (59):keyword based diverse image retrieval with variable multiple instance graph
什么是DAPP系统发展与解析理解
Mysql安装配置以及解决重装Mysql时忘记root password问题
New listing of operation light 3.0 - a sincere work of self subversion across the times!
GCC简介
vsftpd服务的部署及优化
js中的class类模式及语法 2021.11.10
毕业了
选择哪种编程语言,会吸引优秀的人才?
day31 js笔记 DOM下 2021.09.26
Xshell and xftp tutorial