Introspecção em JavaScript

<!DOCTYPE html>
<html>
<head><title>JavaScript Introspection</title></head>
<body>
<script>
var x;

function introspect(object)
{

var type = Object.prototype.toString.call(object);

switch(type){
case '[object Array]':
x
= "array";
break;

case '[object Object]':
x
= "object";
break;

case '[object String]':
x
= "string";
break;

case '[object Number]':
x
= "number";
break;

case '[object Boolean]':
x
= "boolean";
break;

case '[object Date]':
x
= "date";
break;

case '[object Undefined]':
x
= "undefined";
break;

case '[object Null]':
x
= "null";
break;

default:
x
="not recognized";
}}

introspect
(["one","two","three"]);
document
.write(x);
</script></body>
</html>

Para obter mais detalhes, consulte: http://sketchytech.blogspot.co.uk/2013/02/introspection-in-javascript.html