typeof special operatorS2C Home « Operators « typeof

Entity type evaluation.

Description

The typeof special operator returns a string representation of the unevaluated operand type.

Syntax

Signature Description
typeof operandReturns a string representation of the unevaluated operand type.
typeof (operand)Returns a string representation of the unevaluated operand type.
Parameter Description
operandThe entity we wish to return the type for.

Examples

Following are examples of the typeof special operator which stores results in an array for display.


// The typeof operator.
var typeofArray = new Array(11);
typeofArray[0] = typeof ""; // an empty string
typeofArray[1] = typeof "1"; // a string
typeofArray[2] = typeof 1; // a number
typeofArray[3] = typeof 1.1; // a decimal
typeofArray[4] = typeof NaN; // the Not-a-Number global 
typeofArray[5] = typeof undefined; // the undefined global
typeofArray[6] = typeof someVariable; // an undefined varaible
typeofArray[7] = typeof true; // a boolean
typeofArray[8] = typeof false; // a boolean
typeofArray[9] = typeof typeof [1, 2 ,3]; // an object
typeofArray[10] = typeof typeof new Date(); // an object
alert(typeofArray);  

Press the button below to action the above code:


Related Tutorials

General use.

go to home page Homepage go to top of page Top