当我分配给Employee Details对象时,如何从员工中删除额外的字段

时间:2018-09-07 11:07:53

标签: typescript

当我分配给Employee Details对象时,如何从雇员中删除一个多余的字段。

 class EmployeeDetails{
        public empNo:number;
        public  firstName:string;
        public lastName:string;
    }
    var employee = {
        empNo:5,
        firstName:'xyz',
        lastName:'abc',
        department:'development'
    }
    var emp = new EmployeeDetails();
    emp=employee;
console.log(emp);

输出应为::

{  
"empNo":5,            
"firstName":"xyz",
"lastName":"abc"
}

0 个答案:

没有答案