当前位置:网站首页>TypeScript学习
TypeScript学习
2022-08-03 23:57:00 【涵。】
1 any和unknow
unknow只能作为父属性,unknow不能访问对象的属性和方法
2 在对象中引入任意属性
interface p={
age:1
[propName:string]:any
}
3 IArguments类数组
function add(...args:any):void{
let arr:IArguments=arguments
}
4 通过接口定义数组
interface A{
[index:number]:number
}
5 函数重载
function fn(name:string,age:number):void
function fn(name:number):void
function fn(name:any,age?:number):void{
}
6 当返回值类型为boolean,而值类型为number时,使用!!将类型进行强制转换
7 联合类型
interface People={
}
interface Man={
}
const peter=(man:Prople&Man):void=>{
}
8 类型断言
(type as string)或<string>type
9 protected和private的区别
protected内部和子类可以访问,private子类不可以访问
10 设置为static的变量使用类名访问,不需要实例化
class Person{
static age:number=1
}
console(Person.age)
设置为static的方法只能访问设置为static的变量
class Person{
public name:string='xie'
static age:number=1
static show(){
console(this.age)
}
}
11 继承抽象类,抽象方法需要重写
边栏推荐
- Zilliz 2023 Fall Campus Recruitment Officially Launched!
- 初始 List 接口
- The longest substring that cannot have repeating characters in a leetcode/substring
- 【OpenCV图像处理】 图像拼接技术
- Jmeter-断言
- Unity intercepts 3D images and the implementation of picture-in-picture PIP
- It will invest about 200 billion US dollars in the United States in 20 years, and Samsung Electronics looks so handsome
- Redis persistence method
- JS get parameter value of URL hyperlink
- MPLS Comprehensive Experiment
猜你喜欢

【MySQL —— 索引】

Creo 9.0创建几何点

Using matlab to solve the linear optimization problem based on matlab dynamic model of learning notes _11 】 【

Pytest学习-skip/skipif

带你造轮子,自定义一个随意拖拽可吸边的悬浮View组件

Creo 9.0二维草图的诊断:加亮开放端点

代码重构:面向单元测试
![[Paper Reading] TRO 2021: Fail-Safe Motion Planning for Online Verification of Autonomous Vehicles Using Conve](/img/17/342676e20fc04ce9083c5ed443bc1d.png)
[Paper Reading] TRO 2021: Fail-Safe Motion Planning for Online Verification of Autonomous Vehicles Using Conve

苹果对高通说:我4.45亿美元买下一个新园区,可能计划加快基带芯片自研

我的祖国
随机推荐
OpenCV 图像拼接
Jmeter-参数化
Redis persistence method
通过whl安装第三方包
After building the pytorch environment, the pip and conda commands cannot be used
双目IMU标定kalibr
rsync basic usage
数据分析知识点搜集(纯粹的搜集)
vscode插件设置——Golang开发环境配置
易动纷享--测试实习生视频面试
使用unbound在RHEL7上搭建DNS服务
搭建好pytorch环境后,pip和conda指令不能用
689. 三个无重叠子数组的最大和
Three.js入门详解
The curl using guide
3D Semantic Segmentation - 2DPASS
Salesforce的中国区业务可能出现新变化,传言可能正在关闭
国内首发可视化智能调优平台,小龙带你玩转KeenTune UI
Jar a key generation document database
CAS: 178744-28-0, mPEG-DSPE, DSPE-mPEG, methoxy-polyethylene glycol-phosphatidylethanolamine supply