checks if the first argument (or one of its prototypes) is of the type indicated by the second argument.


Let's say you want to write a function which handles vectors, points and lines. One way would be writing: var type = MathLib.type(x); if (type === 'vector' || type === 'point' || type === 'line') { // do something } This can be abbreviated using the function: if (, 'vector')) { // do something } This works because line and point inherit the vector methods.