Javascript isArray and isString

The simplest way to implement isArray and isString in Javascript is to define a boolean property on the prototype.

String.prototype.isString = true;
Array.prototype.isArray   = true;

This technique will of course work for any other class.

Example usage
'abc'.isStringtrue
new String('def').isStringtrue
new Number(1).isStringundefined
new Number(1).toString().isStringtrue

[].isArraytrue
new Array().isArraytrue
{}.isArrayundefined

undefined is equivalent to false in conditional expressions.