Say, I have an object:
const user = {_id: 1234, firstName: 'John', lastName: 'Smith'}
I want to create another object without the _id
key:
const newUser = {firstName: 'John', lastName: 'Smith'}
I am using this:
const newUser = Object.assign({}, {firstName: user.firstName, lastName: user.lastName})
Is there a better way to do this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…