当前位置: 首页 > 文档资料 > Lazy.js 英文文档 >

pluck

优质
小牛编辑
139浏览
2023-12-01

Creates a new sequence whose values are calculated by accessing the specified property from each element in this sequence.

Signature

Sequence.pluck = function(propertyName) { /*...*/ }
Sequence.pluck = function pluck(property) {
  return this.map(property);
}
NameType(s)Description
propertyNamestring

The name of the property to access for every element in this sequence.

returnsSequence

The new sequence.

Examples

var people = [
  { first: "Dan", last: "Tao" },
  { first: "Bob", last: "Smith" }
];

Lazy(people).pluck("last") // sequence: ["Tao", "Smith"]