当前位置:网站首页>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 继承抽象类,抽象方法需要重写
边栏推荐
- 通过whl安装第三方包
- The longest substring that cannot have repeating characters in a leetcode/substring
- jav一键生成数据库文档
- 全球首款量产,获定点最多!这家AVP Tier1如何实现领跑?
- MPLS Comprehensive Experiment
- Unity 截取3D图像 与 画中画PIP的实现
- Read FastDFS in one article
- Three.js入门详解
- 3D Semantic Segmentation - 2DPASS
- A Preliminary Study of RSS Subscription to WeChat Official Account-feed43
猜你喜欢
Jmeter-参数化
【杂项】如何将指定字体装入电脑然后能在Office软件里使用该字体?
[Paper Reading] TRO 2021: Fail-Safe Motion Planning for Online Verification of Autonomous Vehicles Using Conve
corn表达式 具体详解与案例
After building the pytorch environment, the pip and conda commands cannot be used
3D Semantic Segmentation - 2DPASS
Shell 用法梳理总结
Graph-node:创建一个新的subgraph
学习笔记 | uiautomation(如何)实现自动化
20年将投资美国约2000亿美元,三星电子财大气粗的样子真好看
随机推荐
使用unbound在RHEL7上搭建DNS服务
Using matlab to solve the linear optimization problem based on matlab dynamic model of learning notes _11 】 【
MPLS综合实验
internship:编写excel表的上传方法(导入)
响应式织梦模板餐饮酒店类网站
MCS-51单片机,定时1分钟,汇编程序
Unity 截取3D图像 与 画中画PIP的实现
The Chinese Valentine's Day event is romantically launched, don't let the Internet slow down and miss the dark time
Graph-node:创建一个新的subgraph
Redis persistence method
V8中的快慢数组(附源码、图文更易理解)
Flutter教程之为什么 Flutter 是创业的最佳选择?
RSS订阅微信公众号初探-feed43
2021年数据泄露成本报告解读
Prometheus监控Harbor(二进制版)
RSS feeds WeChat public - feed43 asain
利用matlab求解线性优化问题【基于matlab的动力学模型学习笔记_11】
状态机实验
JS获得URL超链接的参数值
Apple told Qualcomm: I bought a new campus for $445 million and may plan to speed up self-development of baseband chips