The simplest way to implement isArray and isString in Javascript is to define a boolean property on the prototype.
This technique will of course work for any other class.
Example usage'abc'.isString | true |
new String('def').isString | true |
new Number(1).isString | undefined |
new Number(1).toString().isString | true |
[].isArray | true |
new Array().isArray | true |
{}.isArray | undefined |
undefined is equivalent to false in conditional expressions.