Is there a way to remove unnecessary properties from the Car
class?
class Car {
wheels: number;
model: string;
}
const obj = {wheels:4, model: 'foo', unwanted1: 'bar', unwantedn: 'kuk'};
const goodCar = filterUnwantedProps(obj); // goodCar only contains fields wheels and model
What is the best method to keep only the existing fields of the Car
class in obj
?