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

invert

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

Returns an ObjectLikeSequence whose values are this sequence's keys, and whose keys are this sequence's values.

Signature

ObjectLikeSequence.invert = function() { /*...*/ }
ObjectLikeSequence.invert = function invert() {
  return new InvertedSequence(this);
}
NameType(s)Description
returnsObjectLikeSequence

A new sequence comprising the inverted keys and values from this sequence.

Examples

Lazy({ first: "Dan", last: "Tao" }).invert() // sequence: { Dan: "first", Tao: "last" }