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
new String('def').isStringtrue
new Number(1).isStringundefined
new Number(1).toString().isStringtrue

new Array().isArraytrue

undefined is equivalent to false in conditional expressions.