Function Keyword Updated 17 Oct 2026
typeof value
The typeof operator returns a string describing the type of the value.
Parameters
valueanyrequiredThe value whose type you want to determine.
Returns
One of "number", "string", "boolean", "function", "object" or "undefined". Arrays, dates and null all give "object" — use Array.isArray() to detect an array. A variable that is not declared gives "undefined".
Example
Normal JavaScript, running in the browser or on the Docly™ server.
write(typeof 123); /* outputs number */
write("\n"); /* new line */
write(typeof "123"); /* outputs string */
write("\n"); /* new line */
write(typeof [1,2,3]); /* outputs object */
write("\n"); /* new line */
write(typeof new Date()); /* outputs object */
write("\n"); /* new line */
write(typeof true); /* outputs boolean */The JavaScript above produces this output:
number
string
object
object
boolean