is


(* → {*}) → a → Boolean

Parameters

  • ctorA constructor
  • valThe value to test

Returns Boolean

Added in v0.3.0

See if an object (i.e. val) is an instance of the supplied constructor. This function will check up the inheritance chain, if any. If val was created using Object.create, R.is(Object, val) === true.

  1. R.is(Object, {}); //=> true
  2. R.is(Number, 1); //=> true
  3. R.is(Object, 1); //=> false
  4. R.is(String, 's'); //=> true
  5. R.is(String, new String('')); //=> true
  6. R.is(Object, new String('')); //=> true
  7. R.is(Object, 's'); //=> false
  8. R.is(Number, {}); //=> false

type


* → String

Parameters

  • valThe value to test

Returns String

Added in v0.8.0

Gives a single-word string description of the (native) type of a value, returning such answers as ‘Object’, ‘Number’, ‘Array’, or ‘Null’. Does not attempt to distinguish user Object types any further, reporting them all as ‘Object’.

  1. R.type({}); //=> "Object"
  2. R.type(1); //=> "Number"
  3. R.type(false); //=> "Boolean"
  4. R.type('s'); //=> "String"
  5. R.type(null); //=> "Null"
  6. R.type([]); //=> "Array"
  7. R.type(/[A-z]/); //=> "RegExp"
  8. R.type(() => {}); //=> "Function"
  9. R.type(async () => {}); //=> "AsyncFunction"
  10. R.type(undefined); //=> "Undefined"
  11. R.type(BigInt(123)); //=> "BigInt"

isNil


* → Boolean

Parameters

  • xThe value to test.

Returns Boolean true if x is undefined or null, otherwise false.

Added in v0.9.0

Checks if the input value is null or undefined.

  1. R.isNil(null); //=> true
  2. R.isNil(undefined); //=> true
  3. R.isNil(0); //=> false
  4. R.isNil([]); //=> false