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

pairs

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

Maps the key/value pairs in this sequence to arrays.

Signature

ObjectLikeSequence.pairs = function() { /*...*/ }
ObjectLikeSequence.pairs = function pairs() {
  return this.map(function(v, k) { return [k, v]; });
}
NameType(s)Description
returnsSequence

An sequence of [key, value] pairs.

Examples

var colorCodes = {
  red: "#f00",
  green: "#0f0",
  blue: "#00f"
};

Lazy(colorCodes).pairs() // sequence: [["red", "#f00"], ["green", "#0f0"], ["blue", "#00f"]]