当前位置:网站首页>Typescript variable declaration - type assertion
Typescript variable declaration - type assertion
2022-06-29 08:35:00 【* listen to the wind】
When the type is not given ,TypeScript The compiler uses type inference to infer types .
If the type cannot be inferred due to lack of declaration , Then its type is regarded as the default dynamic any type .
as follows :
let num = 12; // The type is inferred as number
console.log("num The value of the variable is " + num);
num = "abcde";
Report errors :
First, the variables are declared num, And assignment 12;
Because the variable declaration does not specify a type , therefore , The program applies type inference to determine that the data type of the variable is number.
Next , Trying to give a variable num The assignment is abcde when , Compile error , Because the variable has been set to number type .
边栏推荐
- Summary of various series (harmonic, geometric)
- 各種級數(調和、幾何)總結
- solidity部署和验证代理合约
- [redis] redis6 learning framework ideas and details
- Development trend of garment industry | supply chain | intelligent manufacturing
- P4769-[NOI2018]冒泡排序【组合数学,树状数组】
- 实战回忆录:从Webshell开始突破边界
- Self attention mechanism
- 智能硬件evt dvt pvt mp
- sed 替换值为变量
猜你喜欢

目标跟踪【单目标跟踪(VOT/SOT)、目标检测(detection)、行人重识别(Re-ID)】

Solidity deploy and validate agent contracts

ThreadLocal thread variable

A review of visual SLAM methods for autonomous driving vehicles

Use GPU training in the cloud on the laboratory (take yolov5 as an example)

一个高频问题,三种模型思维来破解此风控难题

Notice on organizing the second round of the Northwest Division (Shaanxi) of the 2021-2022 National Youth electronic information intelligent innovation competition
![[hcie TAC] question 5-2](/img/a5/308aa2cced4cba59354c576a07e3c0.jpg)
[hcie TAC] question 5-2
![[redis] redis6 learning framework ideas and details](/img/64/836b1f8843a8eb91ff8da8c05ccd87.png)
[redis] redis6 learning framework ideas and details

人民链鲍大伟:打破壁垒,建立全域数据治理共享及应用平台
随机推荐
Oracle subquery
语音标注自动音段对齐工具SPPAS使用笔记
Excel中VLOOKUP函数简易使用——精确匹配或近似匹配数据
语音处理工具:sox
[hcie TAC] question 5-2
图文详解JVM中的垃圾回收机制(GC)
802.11--802.11n协议 PHY
Notice on organizing the second round of the Northwest Division (Shaanxi) of the 2021-2022 National Youth electronic information intelligent innovation competition
城通网盘仿蓝奏网盘源码 附带视频教程
A high-frequency problem, three kinds of model thinking to solve this risk control problem
互斥量互斥锁
Paddlenlp general information extraction model: UIE [information extraction {entity relationship extraction, Chinese word segmentation, accurate entity markers, emotion analysis, etc.}, text error cor
Mutex mutex
Debugging nocturnal simulator with ADB command
Is it really safe to open a stock account online? Find the answer
MySQL statistics by day / week / month / quarter / half year / year
VMware vcenter/esxi series vulnerability summary
dcase_ Util tutorial
dcase_util教程
A method to quickly connect notebook computers to mobile phone hotspots