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

pick

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

Creates an ObjectLikeSequence consisting of the key/value pairs from this sequence whose keys are included in the given array of property names.

Signature

ObjectLikeSequence.pick = function(properties) { /*...*/ }
ObjectLikeSequence.pick = function pick(properties) {
  return new PickSequence(this, properties);
}
NameType(s)Description
propertiesArray.<string>

An array of the properties to "pick" from this sequence.

returnsObjectLikeSequence

The new sequence.

Examples

var players = {
  "who": "first",
  "what": "second",
  "i don't know": "third"
};

Lazy(players).pick(["who", "what"]) // sequence: { who: "first", what: "second" }