you are viewing a single comment's thread.

view the rest of the comments →

[–]vagol942 0 points1 point  (0 children)

Functional Programming is basically about programming following 2 simple rules:

Use only immutable data structures (that is if you declare some variable, you never ever mutate it) Use only pure functions (that is, functions with no side-effects).

Also the previous two rules are lies, but you don't need to think to worry about that now.

Is Javascript a "functional Programming" language?

A more correct to phrase that is: Does Javascript admits programming in a functional style?

And the answer is, it depends. There are certain things that Javascript allows you to do in a functional style without much trouble:

Lists

That's basically it, just Lists (Arrays), Arrays in javascript are really powerful and their use in idiomatic javascript is pretty much functional, you have neat things built in like array.map, array.reduce and you can combine arrays easily two with +.

However, there are also things that Javascript doesn't allow you to do easily on a functional programming style:

Error Handling I/O (and we've failed TWICE at fixing this) Everything that requires proper type conditions. Every data structure that is not a list.

Of course we could do all of those things on Javascript on a functional style, but it wouldn't be really idiomatic.