MathLib.type()

MathLib.type returns the type of the argument.

Examples

Here are some examples: MathLib.type(2); // 'number' MathLib.type(true); // 'boolean' MathLib.type(MathLib.complex(3,4)); // 'complex'

Specification

MathLib.type accepts one argument. Any additional arguments will be ignored. The return value is one string.
  • If the argument is null, the result is 'null'.
  • If the argument has a .type attribute, the result is the value of the attribute.
  • Otherwise the result is Object.prototype.toString.call(x).slice(8, -1).toLowerCase() where x is your argument.

Tests