All programming languages have types. These are the building blocks that allow us to write in that language. Understanding types is important if our aim is to master the language.
4. Undefined/absence of a definition
7. object/absence of value
Symbols() came in ES6. A Symbol value is useful in identifying objects. They are usually used for object properties so that the object property is unique.
Technically, functions are objects, underneath it all functions are objects
Let's look at an example to demonstrate.
Functions are objects: Its why we are able to add a property to a function
Primitive and non-primitive types
var a = 5. In memory here, the value is 5 and there is no ambiguity about it.
A variable of a primitive type directly contains a value of that type. null is just null in memory. So is Symbol(), true/false. These can’t be broken down into smaller parts.
A nonprimitive type, on the other hand, doesn't contain an actual value directly.
obj1 doesn't contain the value here directly. Instead, it has a reference — similar to a pointer to somewhere in memory that object is held.
Standard built-in objects come with the language.
However, notice that we also have Strings, Booleans, Numbers for example, even though we said that these are primitives. How come they are objects?
This gets a little complicated.
true is a primitive type but why does it act as an object by using the dot notation?
Behind the scenes, it's almost like wrapping this in a Boolean so that it has access toString() and then finally returns “true”.
So its good to remember that things like Booleans or Strings exist in order for us to be able to use methods on the primitives values.
we get an object. And we do typeof infinity,
we get a number.
Technology will save homo sapiens from extinction