Is Equal

Testing for equality in JavaScript (the language in which Gizmo is implemented) can be challenging as JavaScript casts the values on performing ==

Casting means that data types may be changed as a result of the expression within the Gizmo editor

Whilst the cast can be avoided by using ===, testing equality between Objects directly is not possible

And testing for null and undefined (ie (Blank) values) can have unintended outcomes

The isEq() function allows testing for equality which avoids these surprises

Is a node equal to a value

An example would be to show all nodes at a specific depth in the organisation

nodes().filter((n) => n.depth.isEq(2))

image

Is a node equal to another in hierarchy

In this example the test is to check if the employee is in the same department as their manager

node.department.isEq(node.parent.department)

Which returns the result true or false

image

Does a node share multiple values with another

The isEq() function can be used alongside .pick() to test equality across multiple properties

The expression node.pick("propertykey1", "propertykey2", propertykey3") will get the values held for chosen properties for selected node

while node.parent.pick("propertykey1", "propertykey2", propertykey3") does the same for the parent of the selected node

Combining both of these elements with isEq can test equality across one or more property

node.pick("department", "location", "gender")
    .isEq(node.parent.pick("department", "location", "gender"))

In this example the test is to see if the employee is the same department and location and gender as their manager

image

For more advanced conditional clauses, see is.

results matching ""

    No results matching ""

    results matching ""

      No results matching ""