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

findWhere

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

Returns the first element in this sequence with property names and values matching those of the specified object.

Signature

Sequence.findWhere = function(properties) { /*...*/ }
Sequence.findWhere = function findWhere(properties) {
  return this.where(properties).first();
}
NameType(s)Description
propertiesObject

The properties that should be found on some element in this sequence.

returns*

The found element, or undefined if none exists in this sequence.

Examples

var words = ["foo", "bar"];

Lazy(words).findWhere({ 0: "f" }); // => "foo"
Lazy(words).findWhere({ 0: "z" }); // => undefined