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); }
Name | Type(s) | Description |
---|---|---|
propertyName | string | The name of the property to access for every element in this sequence. |
returns | Sequence | The new sequence. |
Examples
var people = [ { first: "Dan", last: "Tao" }, { first: "Bob", last: "Smith" } ]; Lazy(people).pluck("last") // sequence: ["Tao", "Smith"]