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

intersection

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

Creates a new sequence with all the elements of this sequence that also appear among the specified arguments.

Signature

Sequence.intersection = function(var_args) { /*...*/ }
Sequence.intersection = function intersection(var_args) {
  if (arguments.length === 1 && isArray(arguments[0])) {
return new SimpleIntersectionSequence(this, (/** @type {Array} */ var_args));
  } else {
return new IntersectionSequence(this, arraySlice.call(arguments, 0));
  }
}
NameType(s)Description
var_args...*

The values, or array(s) of values, in which elements from this sequence must also be included to end up in the resulting sequence.

returnsSequence

The new sequence.

Examples

Lazy(["foo", "bar"]).intersection([])             // sequence: []
Lazy(["foo", "bar"]).intersection(["bar", "baz"]) // sequence: ["bar"]
Lazy(["a", "a"]).intersection(["a"])              // sequence: ["a"]
Lazy(["a"]).intersection(["a", "a"])              // sequence: ["a"]
Lazy(["a", "a"]).intersection(["a", "a"])         // sequence: ["a"]
Lazy(["a", "a"]).intersection(["a"], ["a"])       // sequence: ["a"]