const user = {
name: 'jim',
password: '123456',
role: 'admin'
}
const {password, ...result} = user;
console.log(result);
// Output is {"name":"jim","role":"admin"}
const newUser = {passwordHash:'hash(123456)', ...result};
console.log(newUser);
// Output is {"passwordHash":"hash(123456)","name":"jim","role":"admin"}
js 展开符号“...”的用法
最新推荐文章于 2024-07-24 03:28:42 发布