The Typeof Operator : typeof « Operators « JavaScript Tutorial






The typeof operator takes one parameter: the variable or value to check.

var sTemp = "test string";
alert(typeof sTemp);
alert(typeof 95);

Calling typeof on a variable or value returns one of the following values:

  1. "undefined" if the variable is of the Undefined type.
  2. "boolean" if the variable is of the Boolean type.
  3. "number" if the variable is of the Number type.
  4. "string" if the variable is of the String type.
  5. "object" if the variable is of a reference type or of the Null type.








2.13.typeof
2.13.1.The Typeof Operator
2.13.2.typeof
2.13.3.Get variable type
2.13.4.typeof a variable: number
2.13.5.typeof a variable: string