A question about JavaScript

code show as below:

Change English name to Chinese name

const map = {
  id: '编号',
  password: '密码',
  mobile: '手机号',
  username: '姓名',
  timeOfEntry: '入职日期',
  formOfEmployment: '聘用形式',
  correctionTime: '转正日期',
  workNumber: '工号',
  departmentName: '部门',
  staffPhoto: '头像地址'
}
const arr = ['id', 'mobile', 'username']


const change = (map,arr) => arr.reduce((a, b, index) => (a.push(map[arr[index]]), a), [])

const arr2 = change(map, arr)

console.log(arr2) // ['编号', '手机号', '姓名']

Guess you like

Origin blog.csdn.net/qq_52006046/article/details/128540832