Predicate function - Object

The object functions validate object existence, types, and perform comparisons.

  • Comparison predicates use type‑strict evaluation unless explicitly documented otherwise.

  • Unless otherwise stated, range comparisons are inclusive of the minimum and maximum values.

Function

Description

Example

IsDefined(value) Returns true if the value is defined.

  • "hello" is true

  • false is true

  • NaN is true

  • null is false

  • undefined is false

IsUndefined(value) Returns true if the value is undefined (or null in contexts where undefined doesn't exist).

  • undefined is true

  • null is true

  • All defined values is false

IsNull(value) Returns true if the value is null.

  • null is true

  • All other values is false

IsNotNull(value) Returns true if the value is not null.

  • All values except null is true

  • null is false

IsNullOrUndefined(value) Returns true if the value is null or undefined.

  • null is true

  • undefined is true

  • All other values is false

IsType(value, type) Returns true if the value is of a specified type using type object/constructor.

  • IsType(123, typeof(int)) is true

  • IsType(new Date(), Date) is true

  • IsType(null, "string") is false

IsType(value, typeName) Returns true if the value matches a specified type using type name string.

  • IsType("hello", "string") is true

  • IsType([], "Array") is true

  • IsType(123, "string") is false

Equals(value1, value2) Returns true if value1 and value2 are equal.

  • Equals(5, 5) is true

  • Equals({a: 1}, {a: 1}) is true

  • Equals(5, 6) is false

NotEquals(value1, value2) Returns true if value1 and value2 not equal.

  • NotEquals(4, 6) is true

  • NotEquals(4, 4) is false

IsOneOf(value, ...options) Returns true if the value matches any of the specified options.

  • IsOneOf(5, 1, 2, 3, 4, 5) is true

  • IsOneOf(5, 1, 2, 3, 4) is false

IsOneOf(value, options) Returns true if the value matches any value in the provided collection of options.

  • IsOneOf("red", "red, green, blue") is true

  • IsOneOf(5, "1, 2, 3, 4,5") is true

  • IsOneOf(6, "[1,2,3,4,5,6]") is true

  • IsOneOf("yellow", "red,green,blue") is false

IsNotOneOf(value, ...options) Returns true if the value does not match any of the specified options.

  • IsNotOneOf(6, 1,2,3,4,5) is true

  • IsNotOneOf(5, 1,2,3,4,5) is false

IsNotOneOf(value, options) Returns true if the value does not match any value in the provided collection of options.

  • IsNotOneOf(5, "1, 2, 3, 4") is true

  • IsNotOneOf(5, "[2, 5, 6]") is true

  • IsNotOneOf(true, "true,false") is false

IsBetween(value, min, max) Returns true if the number is between the minimum and the maximum range (inclusive).

  • IsBetween(5, 1, 10) is true

  • IsBetween(new Date(2023,5,15), new Date(2023,0,1), new Date(2023,11,31)) is true

  • IsBetween(11, 1, 10) is false