当前位置:网站首页>Generics of typescript
Generics of typescript
2022-06-21 18:27:00 【CupidoZ】
// ts Generic programming for
function add<type>(a:type):type{
return a
}
add("ajaj")
add(123456)
add(false)
// Generic constraint properties
// Constrained generics have a length attribute
function f01<type>(a:type[]):type[]{
console.log(a.length);
return a
}
add("ajaj")
add(123456)
add(false)
// Interface type constraints
function f02<type extends IArguments>(a:type):type{
return a
}
add("ajaj")
add(123456)
add(false)
TS Yes js Added generic support , Parameter encapsulation can be more flexible
边栏推荐
猜你喜欢
随机推荐
PHP的empty,isset和is_null区别
Module import method of node
JZ59.按之字型顺序打印二叉树
使用tidevice启动WDA
服务端socket程序
使用jmeter做Web端自动化测试
最佳网络数据抓包工具mitmproxy
电缆行业产品词可以用line吗?一般不用
雷军的千亿失误?
EtherCAT igh master station controls Esther servo to return to zero
力扣102. 二叉树的层序遍历
高考后网上查询信息,注意防范没有 SSL证书的网站
如何把1000随机分配成10个数
Character processing of node
信创环境下缓存服务Redis集群部署
Check information on the Internet after the college entrance examination, and pay attention to prevent websites without SSL certificates
EtherCAT igh function attempt
TypeScript对象类型
Typescript的构造方式
Inheritance of typescript


![LeetCode 1108 IP地址无效化[暴力] HERODING的LeetCode之路](/img/c6/d3eb6cee92b1c0848bf3d3b58b8b22.png)






