1 2 3 | Object.prototype.toString.call( 'abc' ) // [object String] Object.prototype.toString.call(/abc/) // [object RegExp] Object.prototype.toString.call([ 1 , 2 , 3 ]) // [object Array] |
The full explanation and other ideas are here: http://stackoverflow.com/a/332429/357403