I have an array of objects
student = [{
rollNo: Number,
name: String,
dateOfJoining: Number
}];
Now I'm trying to sort my array inside my function using this code.
students(){
for( let item of res.data){
this.event.push({
name: item.name,
rollNo: item.rollNO,
date: item.joining,
});
}
this.student.sort((val1, val2) => {return val2.dateOfJoining - val1.dateOfJoining});
}
But I'm getting the error "The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type." I know it's because my dateOfJoining is 'Number' and not 'number'.
But I can't write it as 'number' because then I get the error "'number' only refers to a type, but is being used as a value here."