[Vuejs]-Load nested JSON array into select in Vue using computed properties

0👍

Solely considering the code you posted after the Edit , the code can be refactored this way:

let formArray = [];

formArray = this.servicesArray
  .filter(service => service.id == this.service)
  .map(service => service.selectablelocations)
  .reduce((prev, curr) => prev.concat(curr))

return formArray

Note that the map you used doesn’t do anything as Array.prototype.map only returns a new array, but you didn’t assign it to anything.

Leave a comment