Type Checking

The 'typeof' operator returns the type of the argument as a string.
It can also be used with parentheses like a function.

typeof 10            // "number" 
typeof(20) // "number"
typeof 0 // "number"
typeof true // "boolean"
typeof "text" // "string"
typeof Symbol("id") // "symbol"

typeof Math          // "object" 
typeof alert // "function"
typeof undefined // "undefined"
typeof null // "object" - This is incorrect but has not been changed for backwards compatibility

typeof "Wed" === "String"   // true 

© 2020 Better Solutions Limited. All Rights Reserved. © 2020 Better Solutions Limited TopPrevNext