You can use typeof as suggested, but it's not perfect; an array and a Date instance will both be considered to be of type "object".
Another imperfect way to compare by type is this:
function sameTypes() {
var tp = null, ts = Object.prototype.toString;
if (arguments.length === 0) return true; // or false if you prefer
tp = ts.call(arguments[0]);
for (var i = 1; i < arguments.length; ++i)
if (tp !== ts.call(arguments[i])) return false;
return true;
}
You can pass that function two or more (well one or more I guess) values and it'll return true if the result of calling the "toString" function on the Object prototype is the same for all of them. This one's not perfect because it promotes primitives to objects, so a string constant will seem to have the same type as a String instance.