当前位置:网站首页>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
边栏推荐
- 【C Primer Plus第二章課後編程題】
- Huawei's level 22 experts have worked hard for ten years to complete the advanced practical document of cloud native service grid. 6
- MySQL connection query is easy to understand
- pymysql.Error 获取错误码与具体错误信息
- [stm32 Hal library] RTC and BKP drives
- stm32F407-------LCD
- 【狀態機設計】Moore、Mealy狀態機、三段式、二段式、一段式狀態機書寫規範
- 是使用local_setup.bash 还是 setup.bash
- Finally, someone explained the cloud native architecture
- Chapter IV memory management exercise
猜你喜欢

Counting sorting and stability of sorting

Finally, someone explained the cloud native architecture

Association line exploration, how to connect the two nodes of the flow chart

stm32F407-------RTC实时时钟

stm32F407-------外部中断

【状态机设计】Moore、Mealy状态机、三段式、二段式、一段式状态机书写规范

How many locks are added to an update statement? Take you to understand the underlying principles

Cmake tutorial (I)

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

stm32F407-------寄存器地址名称映射分析
随机推荐
Yyds dry goods count 【 vs code work record III 】 set vs code format
PHP 使用endroid/qrcode 二维码生成, GD库生成分享海报
ROS2中的行为树 BehaviorTree
【C Primer Plus第二章課後編程題】
这样学习二叉树
window10 phpstudy 安装redis扩展
Mysql-5.7.30-winx64 installation free download and installation tutorial
股票开户在网上开通安全吗?
PHP利用CURL实现登录网站后下载Excel文件
Blue Bridge Cup top ten common heaven level skill - breath of water The type of one recursion
Machine learning 6-decision tree
pymysql. Error get error code and specific error information
Design e-commerce seckill system
Yes, use local_ setup. Bash or setup bash
Yyds dry inventory solution sword finger offer: maximum sum of continuous subarrays (II)
stm32F407-------寄存器地址名称映射分析
Three communication skills in software testing
[Electronic Experiment 2] simple electronic doorbell
Stm32f407------- general timer
Scrapy使用xlwt实现将数据以Excel格式导出的Exporter