当前位置:网站首页>Reduction of type
Reduction of type
2022-07-18 13:43:00 【To be a woman of light】
1.typeOf
//1.typeof The type of
type IDType=number |string
function printID(id:IDType){
if(typeof id==="string"){ // If id The type of is a string when
console.log(id.toLowerCase())
}else{
console.log(id)
}
}2. The type of equality is reduced (=== ==! !=)
3.instanceof Is an example of a certain type
// When judging whether the object is an instance ,
function printTime(time:string|Date) {
if(time instanceof Date){
// When time yes Date The type of time , Can be converted into
console.log(time.toISOString())
}else{
console.log(time.toUpperCase())
}边栏推荐
- [TinyML]NetAug:Network Augmentation for Tiny Deep Learning
- Exploratory software testing
- ESP8266+Blinker+WEB配网
- 2.18 haas506 2.0 development tutorial - communication between Alibaba cloud M2M devices - rule engine /topic message routing (only versions above 2.2 are supported)
- node请求页面时自动下载
- MySQL 窗函数 流动平均数 running average
- The third day of MATLAB learning (data types, operators and various operations)
- "Harmonyos" explore harmonyos applications
- idea 将dev分支代码合并到master类推
- July 2022 information theory Wu Jun
猜你喜欢

三匹马携手乾元公益基金会 | 炎夏送清凉,致敬坚守者 !

递归求解二叉树的遍历(常考基础例题)

Dpdk flow filter summary (flow director/ rte_flow)

in_ Example analysis of the third parameter of array

28K monthly salary for software testing interview questions for large factories (you can take away the test paper with the permission of the interviewer)

Dls-12b/dc220v double position relay

Sword finger offer 10- ii Frog jumping on steps

5、 Basic composition & assertion of JMeter script

Hcip the next day

老子云3D产品及服务全介绍,一张图告诉你如何选!
随机推荐
Common protocols of tcp/ip
constrained graphic layout generation via latent optimization
Basic UNIX domain protocol programming
DLS-12B/DC220V双位置继电器
三匹马携手乾元公益基金会 | 炎夏送清凉,致敬坚守者 !
猜数字大小II[动态规划解决什么问题?]
ORA-19625异常处理记录
Flutter ListView controller.animateTo 无效
【深度学习】《动手学深度学习》环境配置
"Harmonyos" explore harmonyos applications
More than 130 enterprises and 3500 developers have jointly built the root community of opengauss open source database
视频处理:视频抽样
312312dd
Dpdk flow filter summary (flow director/ rte_flow)
Sword finger offer 10- I. Fibonacci sequence
Dual position relay dls-5/1
Excel, how to choose the right chart?
【独立站运营】一分钟读懂跨境电商运营四大技巧!
单细胞论文记录(part15)--Integrated analysis of multimodal single-cell data
Software testing zero basic testing - Basic Concepts