current position:Home>Winter vacation javascript cram school Chapter 2 let & const temporary dead zone
Winter vacation javascript cram school Chapter 2 let & const temporary dead zone
2023-01-25 10:50:36【small fish programmer】
The performance of temporary dead zone
if (true) {
console. log(value);
let value = 1;
}
Uncaught ReferenceError: Cannot access 'value' before initialization
var:
1. In ES5, it is a global variable, a top-level variable (referring to window)
2. There is a case of variable promotion
console.log(a) //undefined
var a=10
This code will be transformed into the following
var a
consolse.log(a)
a=10
3. The statement can be repeated, and the final result is that the last one will overwrite the previous variable
4. Using var in a function is a local variable, and directly using a variable in a function is a global variable (no var)
let:
1. The scope of let is block-level code, which is only valid in code blocks.
2. There is no variable promotion (temporary dead zone)
3. Duplicate definitions are not allowed
const:
1. const declares a read-only constant. Once declared, the value of the constant cannot be changed
2. If you have declared a variable with var or let before, you will also report an error if you declare it with const
3. There is no variable promotion (temporary dead zone)
This also reflects the safety of let and const
copyright notice
author[small fish programmer],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2023/025/202301251040055537.html
The sidebar is recommended
- Freespire 9.0 released, Ubuntu-based Linux distribution
- k8s kubeadm init error "unknown service runtime.v1alpha2.RuntimeService"
- Spring Boot Admin 3.0 Released, Admin UI for Spring Boot Applications
- Android 14 will prohibit sideloading of some apps
- uninstall docker
- The relationship between the library, schema and table space of the National People's Congress Jincang database
- sqlalchemy DetachedInstanceError: Instance
is not bound to a Session - k8s dashboard deployment
- Management system template source code based on Echo+Vue+ElementUI
- Based on the Echo + + the Vue ElementUI electrical contractor background management system
guess what you like
[Self-study on the principles of artificial intelligence] Deep Learning: Magical Deep Learning
Linux system installed jmeter
[linux] Several ways to check the version information of Linux system
Control statements perfect small lucky draw program - basic knowledge of Java
7.Java Judgment and Loop + Interview-related Deduction Algorithm Questions Detailed Explanation
Java introduction and environment construction
Analysis of Crash Principle in Java Layer for Crash Optimization
Build a local Maven warehouse
Based on VirtualBox centos7 virtual machine installation
JVM process cache - Caffeine
Random recommended
- Background management system scaffolding built by Revel+Vue+ElementUI framework
- Replace source of ubuntu virtual machine and configure Samba server
- Code Caprice No24 | Backtracking Algorithm Theoretical Basis, 77. Combination
- The Road to Algorithm Practice——[String] Leetcode 824 Goat Latin
- Git summary - Prompt to submit or temporarily store changes when switching to a branch
- Productivity tools - [gitlab configuration] One-time configuration of GitLab account
- Echo+Vue+ElementUI management background source code
- Revel+Vue+ElementUI framework use and build tutorial
- Basic practice tutorial of Revel+Vue+ElementUI framework
- Go Web Development Revel+Vue+ElementUI Framework Practical Tutorial
- Construction and deployment tutorial of Revel+Vue+ElementUI framework
- 8. Java loop advanced comprehensive exercises - infinite loop and jump control statement, every seven passes, square root, judging whether it is a prime number, guessing number games
- Control statement + exception handling perfect lucky draw applet-java basics
- 9. Java Array Knowledge Encyclopedia
- Lucky draw applet-java basics
- Java basic implementation calculator applet
- The front end of actual combat: copy write millet's official website on the first day
- 1. Linux application programming and network programming---file IO notes in Linux system
- 7. Linux application programming and network programming --- thread full solution Notes
- [Front-end notes - CSS] 10. Cascading and inheritance + selector
- 8. Linux application programming and network programming---Linux network programming notes
- [Java|golang] 1828. Count the number of points in a circle
- Add environment variables under Linux system and will not overwrite the previous method of adding environment variables
- 2 · Linux application programming and network programming - file attributes notes
- Redis interview questions (classic 7 questions)
- [Front-end notes——CSS] 11. Box model + background and border
- C + + large Numbers together, according to a combined
- 3. Linux application programming and network programming --- get system information notes
- The use and principle of Kafka message queue
- 5. Linux application programming and network programming---signal notes in Linux
- 6 · Linux application programming and system programming - senior IO notes
- Java collection common interview questions (4)
- 072-JAVA project training: Imitation QQ instant messaging software series lecture 7 (explaining the realization of the chat interface and functions)
- Coordination center performance comparison: how zookeeper solves the load balancing problem
- 070-JAVA project training: imitation QQ instant messaging software series lecture five (explain user registration function)
- Ubuntu installation and configuration (brief)
- 073-JAVA project training: imitation QQ instant messaging software series lecture eight (explain query and add friend function)
- SQL injection classification and error injection EXP
- All basic commands in linux fail, showing that the command cannot be found
- 4. Linux application programming and network programming---Linux process full solution notes (difference between process and program)