当前位置:网站首页>TS union type
TS union type
2022-07-25 23:21:00 【Intern Sen】
TS Joint type
Joint type That is, through the pipeline | Set variables to multiple types , The assignment can be made according to the type of setting .
1 Common variable declaration
let res: number|string|boolean
res = 12
res = ' Xiao Xu '
res= true
// Only the specified type can be assigned , If other types are assigned, an error will be reported .
2 Array declaration uses
let arr: number[]|string[]
arr = [1,2]
arr = ['xiao','xu']
3 Use in a function
const test = (p: string | number) => {
... }
边栏推荐
- 行云管家V6.5.1/2/3系列版本发布:数据库OpenAPI能力持续强化
- Summary of built-in instructions and custom instructions
- How to set pseudo static for WordPress fixed links
- MVVM model
- Details of notification (status bar notification)
- [QNX hypervisor 2.2 user manual]9.8 load
- Thinkphp6 temporarily close the layout
- Mongodb的特点、与MySQL的差别、以及应用场景
- serialization and deserialization
- 新手开户选择哪个券商公司好呢?安全吗
猜你喜欢

MathType安装和解决不能Crtl+V的问题

XXE&XML-外部实体注入-利用和绕过

How does PHP remove an element from an array based on the key value

Drive board network cable directly connected to computer shared network configuration

Zero crossing position search of discrete data (array)

POI特效 市场调研

E-commerce RPA, a magic weapon to promote easy entry

类和对象(3)

The new UI people help task help PHP source code with a value of 1500 / reward task Tiktok Kwai headline like source code / with three-level distribution can be packaged applet

What has Amazon cloud technology done right to become the leader of cloud AI services for three consecutive years?
随机推荐
【微信小程序】页面导航
r语言绘图参数(R语言plot画图)
ETL工具(数据同步) 二
[interface performance optimization] reasons for index failure and how to optimize SQL
Node基础
Redis expiration key deletion strategy [easy to understand]
Explain in detail the addition (+) operation in JS, basic data type addition, reference data type addition, and the underlying operation rules, [] + {}, {} + []
[QNX Hypervisor 2.2用户手册]9.6 gdb
Zero crossing position search of discrete data (array)
Sichuan cuisine menu (I)
Check code generation
Tips for using (1)
AI chief architect 12 AICA industrial landing analysis under the industrial production process optimization scenario
MVVM model
WebMvcConfigurationSupport
Longitude and latitude and its transformation with coordinate system
Circle detection and line detection of PCL
TS basic data type
Rendering, filtering (filtering) and sorting of lists
自定义mvc原理