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; }, {}); }
Name | Type(s) | Description |
---|---|---|
returns | Object | 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" }