当前位置:网站首页>TypeScript -- 第二节:变量声明
TypeScript -- 第二节:变量声明
2022-06-28 23:43:00 【Run Coder】
变量声明

此章节介绍的变量声明(var let const)是基于JavaScript的,使用的方法一模一样。
再简单熟悉一下使用方法
- var(不建议使用)
·用于声明全局作用域 和 局部作用域(或叫函数作用域),不可以声明块级作用域
·存在变量提升
·可以使用var声明重复的变量名,前边的会被后边的覆盖。 - let(建议使用)
·用于声明块级作用域。例如{},是一个作用域
·不存在变量提升
·同一个作用域内重复声明变量,会报错
·暂时性死区(TDZ)。意思是变量在作用域内已经存在,必须在 let / const声明后面使用;TDZ能够让开发者养成先声明后使用的习惯,让程序更加的稳定 - const(建议使用)
·const 声明一个只读的常量,一旦声明,常量值就不可以改变。所以const一旦声明就必须立即初始化。
·除了第一条,其他的类似于let
·小知识补充:一般用于声明常量的变量名字使用大写字母,约定成俗,就像构造函数的名字首字母大写一样。
- 简单的事情重复做,认真做!!! --wcc
边栏推荐
- Use conditional breakpoints in vscode (based on GDB)
- [software analysis] iterative explanation of software analysis, design and modeling
- Have you ever met a fake interview in a job interview? How to avoid?
- stm32F407-------外部中断
- [C Primer Plus Chapter II after class programming questions]
- 解决ConfigParser解析中文问题
- Count the number of arrays with pointers
- The picture display on the left of the two column layout is determined by the content height on the right
- Yyds dry goods count 【 vs code work record III 】 set vs code format
- Stm32f407 ------- IO pin multiplexing mapping
猜你喜欢

stm32F407-------NVIC中断优先级管理
![Edge extraction based on Halcon learning [2] circles Hdev routine](/img/e4/e3738d71c2ff5a239a12f67d06e2c9.jpg)
Edge extraction based on Halcon learning [2] circles Hdev routine
![[API packet capturing in selenium automation] installation and configuration of browsermobproxy](/img/67/3e15b2191ee23a8c4453aad007651d.png)
[API packet capturing in selenium automation] installation and configuration of browsermobproxy

mysql-5.7.30-winx64免安装版下载安装教程

Mobile heterogeneous computing technology - GPU OpenCL programming (basic)

stm32F407-------GPIO输入实验

At the end of June, how many people in Kangkang are ready to change jobs

Interviewer: what is the internal implementation of strings in redis?

Implementation of dynamic timer for quartz

Stm32f407 ------- IO pin multiplexing mapping
随机推荐
PHP uses curl to download Excel files after logging in to the website
力扣(LeetCode)178. 分数排名(2022.06.27)
PHP利用CURL实现登录网站后下载Excel文件
What is the lifecycle of automated testing?
Is it safe and reliable to open a securities account in Yixue school?
Mobile heterogeneous computing technology - GPU OpenCL programming (basic)
Quartz explanation and use
[Electronic Experiment 2] simple electronic doorbell
The secondary market is full of bad news. How should the market go next? One article will show you the general trend
stm32F407-------串行(串口)通信
Huawei's level 22 experts have worked hard for ten years to complete the advanced practical document of cloud native service grid. 6
Association line exploration, how to connect the two nodes of the flow chart
Implementation of dynamic timer for quartz
[stm32 Hal library] serial port communication
ERROR 1067 (42000): Invalid default value for ‘end_ time‘ Mysql
Edge extraction based on Halcon learning [2] circles Hdev routine
Machine learning 4-dimension reduction technology
Counting sorting and stability of sorting
股票开户在网上开通安全吗?
[stm32 HAL库] RTC和BKP驱动