Day 62 JavaScript Operators Are Functions & Functions Are Objects

Hello coders today I listened to more of the Anthony Alicea course. Some interesting concepts were clicking together today.

For example how operators are just functions that return values. Similar to how (+-*/) are all operators that return a value, comparisons were as well. Functions innovate code to run with parenthesis (), essentially an operator. At the same time functions are also objects.

Objects are just name value pairs with more name value pairs within itself. Functions are similar to objects when you create first class functions. First class functions can do everything you can do with other types. Like assign them variables, pass them around, create them on the fly. Functions are able to mimic objects due to JavaScript being dynamically typed.

Meaning that JavaScript engine tries to figure out types (number,Boolean, string, object, etc.) on the fly. I found out that this is a powerful feature within JavaScript that most languages cannot take advantage of since most are statically typed, meaning that they do not automatically parse different types. Essentially you are able to make functions within functions to make predictable code results.

You can add properties to a function by assigning it in memory by reference. Meaning that if you set a variable to a function it creates space for it in the memory by using the equal operator. You are able to make changes to a function within its parameters even if it’s a child element effecting the parent function element. This is possible because both variables are referencing the same place in memory and how the JavaScript engine parses through the code.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Up ↑

%d bloggers like this: