Investigate functions
Functions might be objects, but they certainly aren't plain! They are also not just a way to run logic. They have many amazing characteristics that are the key to scope, closures, the this variable and so many other concepts.
Let’s first get the type of a function using typeof.
What would you expect to see if we decided to execute the function? Comment out the second log.
Functions as objects
You may have heard the old saying, “everything in JavaScript is an object”. We already know that’s not true - primitives are not flying ships. But since functions are meant to be objects, let's test this theory...
Try adding some properties to the function like you would a normal object, and then accessing them. Do you think it will work? 🤔
What about methods? Can we add a method inside a function - a function inside a function 😲
Let's turn our attention to executing functions.
What happens if we forget the () when executing a function? What do you expect to see in the console?