let list = [ { key: 'php', value: '1' }, { key: 'asp', value: '2' }, { key: 'aspx', value: '3' }, { key: 'jsp', value: '4' } ] let header = {} list.forEach(({ key, value }) => header[key] = value); //打印结果为以下 //{ php: '1',asp: '2',aspx: '3',jsp: '4'}
let list = [] let header = { 'php': '1', 'asp': '2', 'aspx': '3' } Object.keys(header).some((key) => { list.push({ key: key, value: header[key] }) }) //打印结果为以下 // [{ key: 'php', value: '1' },{ key: 'asp', value: '2' },{ key: 'aspx', value: '3' }]
标签:asp,list,value,header,let,key From: https://www.cnblogs.com/yundeblog/p/17240576.html