[Solved] How to retrieve object property values with JavaScript?


You can use the map() method along with the ES6 fat arrow function expression to retrieve the values in one line like this:

users.map(x => x.mobile);

Check the Code Snippet below for a practical example of the ES6 approach above:

var users = [{mobile:'88005895##'},{mobile:'78408584##'},{mobile:'88008335##'}];
       
var mob = users.map(x => x.mobile);

console.log(mob);

Or if you prefer an ES5 approach without the fat arrow function, you can map the array like this:

users.map(function(x) {
  return x.mobile;
});

Check the Code Snippet below for a practical example of the ES5 approach above:

var users = [{mobile:'88005895##'},{mobile:'78408584##'},{mobile:'88008335##'}];
       
var mob = users.map( function(x) {
  return x.mobile;
});

console.log(mob);

solved How to retrieve object property values with JavaScript?