

while and for loops may be used to filter, find or do something to each value inside the array. In JavaScript, we often work with arrays but a lot of developers tend to use an imperative pattern when it’s not necessary. That’s what functional programming is in a nutshell. It doesn’t matter in which order you put in the sugar and coffee powder - as long as it’s in the mug. For example, the task of making instant coffee. There are some scenarios where the order doesn’t matter as much. For some circumstances, a procedural pattern is necessary but it’s not required for all scenarios. Else try again.Įach step in the process needs to be done in order for the final outcome to occur. Else proceed to turn computer on.Įnter password. Take a look at the procedural model below: Start. This is code that’s written in a way that represents a flow of thought, resulting in a series of dependencies for the chain to work. The Quick Lowdown on Functional ProgrammingĪ lot of smelly JavaScript code is written in an imperative or procedural pattern. This is where functional patterns come in. A lot of developers tend to write their code in a procedural manner - where one blip in the procedure can break the code or create side-effect bugs.

JavaScript is a language that’s prone to imperative patterns because of how easy it is to pick up.

When it comes to functional programming, it’s more to do with the processes that get you from point A to point B than how data and groups of business logic are structured.
