pluck.js 310 B

123456789101112131415
  1. var map = require('./map')
  2. var property = require('./property')
  3. /**
  4. * 获取数组对象中某属性值,返回一个数组
  5. *
  6. * @param {Array} array 数组
  7. * @param {String} key 属性值
  8. * @return {Array}
  9. */
  10. function pluck (obj, key) {
  11. return map(obj, property(key))
  12. }
  13. module.exports = pluck