자바스크립트 관련 주제

아래와 같이 코드 쇼:

영어 이름을 중국어 이름으로 변경

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) // ['编号', '手机号', '姓名']

추천

출처blog.csdn.net/qq_52006046/article/details/128540832