typeof value Last updated: 17. Oct 2026
Keyword
The typeof operator returns a string describing the type of the value.
Parameters
| Name | Type | Description |
|---|---|---|
| value | any | The 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
Code example (JS)
JS is normal JavaScript either 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 */ Output
The JS code above produces the output shown below:number
string
object
object
boolean