Member-only story
Functional vs Procedural JavaScript
So, I hate JavaScript. Well at least I used to; because I misunderstood it. Before JavaScript, I was mostly a .NET and PHP guy and approached JS the wrong way. Here is why.
There are two major programming paradigms: Procedural Programming, which is based on concepts of procedure-call-like routines and subroutines and Functional Programming, which is based on expressions like variables, constants, functions and operators. Some commonly used procedural languages today are PHP, Java, C/C++, Python and C# while the more commonly known functional programming languages are Haskell, Lisp, Clojure, R and Erlang. Today, most languages support both procedural and functional programming (Scala, C# 2.5 +, Java 8 and Php 5.3+ for example) but JavaScript takes the best of both worlds.
Procedural programming typically involves your code executing at the top of your script and going in order, statement by statement, to the bottom. Functional programming, however, centers more around the idea of the programming describing what should be done to an input and less around the order in which that should occur.
To better understand these concepts, let’s build a function that gets a property from an object and see how the Imperative (Procedural) and Declarative (Functional) approaches differ.