我有一个像这样的对象数组:
const customers = [
{
customer_name: 'Negan',
customer_age: 45,
customer_weapon: 'Bat',
customer_email: 'negan@sanctuary.com',
customer_city: 'Washington'
},
{
customer_name: 'Daryl',
customer_age: 41,
customer_weapon: 'Crossbow',
customer_email: 'daryl.dixon@kickass.com',
customer_city: 'Atlanta'
},
{
customer_name: 'Rick',
customer_age: 45,
customer_weapon: 'Magnum 357',
customer_email: 'rick@alexandria.com',
customer_city: 'King County'
},
]
我希望替换对象中所有键,这些键为:
const newKeys = [
'firstname',
'age',
'weapon',
'email',
'city'
]
如何最好地做到这一点?提供一个例子将会更好!