How to extract a property from array of objects and slice it?

后端 未结 2 1029
故里飘歌
故里飘歌 2021-01-28 01:21

so i have an array of objects which returns phoneNumber and businessNumber and name. I am trying to extract the businessNumber and phoneNumber and want to slice them from \"-\"

2条回答
  •  太阳男子
    2021-01-28 02:10

    you could return both numbers in an array of new objects

    let arr1 = myArray.map(function(obj) {
      return {
        businessNumber: obj.businessNumber.split('-').pop(),
        phoneNumber: obj.phoneNumber.split('-').pop() 
      }
    })
    

提交回复
热议问题