I expect that a class return an array when I new it
class MyArray {
constructor(){
}
}
const myArray = new MyArray()
Array.isArray(myArray) // Should be true
I used to write it in this way:
class MyArray {
constructor(){
const arry = new Array()
return arry
}
}
But when I write in Typescript,the return value arry is not the type of MyArray, so it prompt an error.
How to fixed this problem?
Array.isArray(myArray)betruewhen it's obviously aclassand not an array.