Closed notflybird closed 3 weeks ago
我明白了,从父集和子集包含关系来说:父类型定义的内容,子类型肯定能是有的,因为子类型继承父类型,然后子类型可以在定义一些自己内容;readonly number[]作为父类型,有“读取”方法、获取数组长度等,number[]子类型继承父类型,在原来的基础上,新增push、pop、unshift、shift等方法;这样就导致子类型number[]在父类型基础上进行了扩展;所以number[]值可以赋值给readonly number[],但是反过来不行,因为readonly number[]类型值,没有push,pop等方法。不知道理解的对吗?