Lodash - objects

About

These functions provide key functionality for working with objects that is missing from 4D.

API

.assign()

.assign(target : Object; source : Object { ; …sourceN : Object }) : Object

Merges one or more source objects with target. Only enumerable properties in sources are copied. Source properties later in the parameter list overwrite earlier ones. Null/undefined sources are ignored.

This function mutates and returns target. To merge multiple objects into a completely new object, pass an empty object as target.

NOTE

This function assigns properties from the sources to target, it does not copy. If you need a deep copy of the sources, use OB Copy(target) after calling this function.

Example

$o1:=New object("a"; 7; "b"; "foo")
$o2:=New object("a"; 13; "b"; "bar")
$o3:=New object("a"; 27; "c"; "baz")
_.assign($o1; $o2; $o3)
// $o1 => { a: 27, b: "bar", c: "baz" }

$o1:=New object("a"; 7; "b"; "foo")
$result:=_.assign(New object(); $o1; $o2; $o3)
// $o1 => { a: 7, b: "foo" }
// $result => { a: 27, b: "bar", c: "baz" }

.equalObjects()

.equalObjects(object : Object; compare : Object { ; strict : Boolean }) : Boolean

Compares object with compare recursively and returns whether or not they are equal. To be considered equal, object and compare must:

  • Have the same set of keys
  • Have corresponding values where _.equal() returns true

If strict is true, text properties are compared using case/diacritical-sensitive comparisons.


.strictEqualObjects()

.strictEqualObjects(object : Object; compare : Object) : Boolean

This is a convenience function that is the equivalent of _.equal(object; compare; True).

Last Updated:
Contributors: Aparajita