Getting the values for a specific key from all objects in an array [duplicate]

You could map:

permittedValues = array.map(function(value) {
  return value.key;
});

In ES6/ES2015 it’s even prettier with arrow functions:

permittedValues = array.map(value => value.key);

It might be prettier, but it’s probably not faster than a for() loop.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)