JavaScript only checks types in run-time. Dynamic type checking uses one of two operators:
typeof
is a unary operator, for readability it is
recommended to write it like a function call instead.typeof(value)
instead of typeof value
.
typeof(Object.notDefined)
"undefined"
typeof(null)
"object"
typeof(true)
"boolean"
typeof(42)
"number"
typeof("")
"string"
typeof({ key: 'value' })
"object"
typeof([1, 2, 3])
"object"
[1, 2, 3] instanceof Array
true
[1, 2, 3] instanceof Object
true
42 instanceof Number
false
typeof(function () {})
"function"
(function () {}) instanceof Object
true
The console allows you to interact with the course material and examples. Use the following keys:
A special logging function is also available: