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

assign

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

Returns an ObjectLikeSequence whose elements are the combination of this sequence and another object. In the case of a key appearing in both this sequence and the given object, the other object's value will override the one in this sequence.

Signature

ObjectLikeSequence.assign = function(other) { /*...*/ }
ObjectLikeSequence.assign = function assign(other) {
  return new AssignSequence(this, other);
}
NameType(s)Description
otherObject

The other object to assign to this sequence.

returnsObjectLikeSequence

A new sequence comprising elements from this sequence plus the contents of other.

Examples

Lazy({ "uno": 1, "dos": 2 }).assign({ "tres": 3 })     // sequence: { uno: 1, dos: 2, tres: 3 }
Lazy({ foo: "bar" }).assign({ foo: "baz" });           // sequence: { foo: "baz" }
Lazy({ foo: 'foo' }).assign({ foo: false }).get('foo') // false