Js array problem

there is an array from which you want to get a new array with a slightly different structure.

/ / there is now an array of alist

var alist=[
    {"name":"sh","tel":"13435555454","id":1},
    {"name":"kk","tel":"1343566454","id":2},
    {"name":"rr","tel":"1343937454","id":3}
]

/ / if you want to generate a blist based on the above alist, take each item of the alist to get the following new list, which requires that the positionName attribute corresponds to the name attribute and the contactId attribute corresponds to the id attribute

blist=[
    {"positionName":"sh","contactId":1},
    {"positionName":"kk","contactId":2},
    {"positionName":"rr","contactId":3}
]

how can it be realized? Front-end rookie, do not have a solid grasp of some data operations of js. The God of trouble instructed 0.0

May.07,2022

var blist = alist.map(function(obj){
   return {
        positionName:obj.name,
        contactId:obj.id
     }
})

the for loop assigns values in turn? The code is as follows:

var blist = [];
for(var i of alist){
    blist.push({'positionName':i.name,'contactId':i.id});
}

clipboard.png


const blist = alist.map(({ name, id }) => ({
  positionName: name,
  contactId: id,
}))
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e4bc3b-441b5.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e4bc3b-441b5.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?