typeof operator tells you what type a primitive value is.
It is important to note that strings can be either a primitive, string literal,
the user to use the handy array of functions available for use.
If you wanted to convert a string object to a primitive, you would
let message = "Hello World"; typeof message; // 'string'
In other programming languages, you can have numbers be defined as floats, integers,
every number it comes across
Number, with an exception.
let password = 123456789; typeof password; // 'number'
This is similar to
Number however, it allows you to safely represent integer values
larger than 253. You can create a
bigint by appending n to the end of the
number or by wrapping the number, or string for this case, in the
let launchCodes = 66777888889999912345n; typeof launchCodes; // 'bigint'
This data type is what contains the values
false. This is great in that
you can use other values to represent that same concept like 0 for false, and 1 for true.
isBool = true; typeof isBool; // 'boolean' // Instances of wrapper classes, like `Boolean`, are objects, **not** primitives. typeof new Boolean(isBool); // 'object'
This value is automatically assigned to variables that have just been declared but not defined.
If you were to put this in an if statement, the value would be false so this is another handy thing
you could use like mentioned in the
let x; typeof x; // 'undefined'
A Symbol is a value created by invoking the
which is guaranteed to create a unique value. It takes one parameter, a string
will show up when you print the symbol.
let x = Symbol("this is a symbol"); typeof x; // 'symbol'
null is special because the
typeof operator reports its type as 'object'.
typeof null; // 'object'