Extract attribute from array - Node.js Array

Node.js examples for Array:Array Operation

Description

Extract attribute from array

Demo Code


"use strict";//from   w  w w.ja  v  a2s  .  c  om

Array.prototype.extract = function(attribute) {
  var newArr = [];
  
  for (var i = 0; i < this.length; i++) {
    newArr.push(this[i][attribute]);
  }
  
  return newArr;
}

Related Tutorials