DEV Community

Discussion on: Writing modern JavaScript code

Collapse
 
anortef profile image
Adrián Norte

"The reason? It makes the code more predictible, safer, deterministic, and a lot easier to maintain when you're used to it."

Can you elaborate why? I have never programmed in a functional way in a serious project so I would like to know the reason behind those affirmations.

Thanks.

Collapse
 
mkwong268 profile image
Mitchell

One of the keys to functional programming is no side effects. So code inside the function shouldn't affect things outside of the function.

Another key of functional programming is that functions should not be affected by things outside of it's scope. (ie: For any given set of parameters the function will always have the same return for that set of parameters).

Keeping these in mind will make code more predictable and safer.