Map对象: map数据结构是我最喜欢的数据结构,可以对他来对两次以上数组遍历的代码进行优化,降低代码时间复杂度, 深得我心!
const map = new Map()
map方法:
clear()
set()
get()
has()
delete()
size属性, 返回map中的键值对的数量
keys()
values()
遍历: for( let [key, value] of newMap) {}
元组: 一个数组中存储不同的类型的元素,元组可作为参数传递给函数
[1, 'bog']
联合类型:
const val: string | number | string[]
接口:
interface interName {
firstName: string,
lastName: string,
sayHi: () =>string,
}
联合类型和接口:
interface interName{
program: string,
command: string[] | string | (()=>string)
}
接口和数组:
interface interfaceName {
[index: string]: string,
}
const list: interfaceName = ['bob', 'gogle', 'sdn']
接口继承:
interface Person {
age: number
}
interface Music extends Person {
name: string
}
const person: Music = {
age: 23, name: 'an'
}
const person1 = <Musician>{} person1.age = 33, persion.name = 'sun'
多继承实例:
interface parent1 {
val1: number
}
interface parent2 {
val2: number
}
interface Child extends parent1, parent2 {}
const children: Child o= {val1: 23, val2: 323 }