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

toObject

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

Creates an object with the key/value pairs from this sequence.

Signature

ObjectLikeSequence.toObject = function() { /*...*/ }
ObjectLikeSequence.toObject = function toObject() {
  return this.reduce(function(object, value, key) {
object[key] = value;
return object;
  }, {});
}
NameType(s)Description
returnsObject

An object with the same key/value pairs as this sequence.

Examples

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

Lazy(colorCodes).toObject() // => { red: "#f00", green: "#0f0", blue: "#00f" }