// This is a modified version of the same function found in
// Microsoft's JScript Language Reference v5.6
// (section "instanceof Operator" under "Operators").
// This version tests for more classes, has a more compact test
// (using the conditional ?: operator), and more meaningful variable names.

function objTest(thisObj){
	var testClass, testArray, resultString = "";   // Create variables.
 	testArray = new Array();   // Create an array.
	// Populate the array with pointers to the commonly used classes
	testArray["Object"] = Object;
	testArray["Date"] = Date;
	testArray["Array"] = Array;
	testArray["Number"] = Number;
	testArray["String"] = String;
	testArray["RegExp"] = RegExp;

	for (testClass in testArray) {
		resultString += "object is"
			+ (thisObj instanceof testArray[testClass] ? "" : " not")
			+ " an instance of " + testClass + "\n";
	}
	return(resultString);   // Return string.
}