DEV Community

Discussion on: Functional Programming in JavaScript? Yes, Please.

Collapse
 
vogtis profile image
Vogtis

why in heaven can't you use regular quotes (') so one can copypaste the code and play around? and why don't you use arrows to make code short, like it's 2017?

let cats = animals.filter(a=>a.species==='cats');

Collapse
 
damcosset profile image
Damien Cosset

Is this really a constructive comment? The author's code is readable and correct. Using arrow functions doesn't change the point of the article.

Collapse
 
pamblam profile image
Rob Parham

sort of does actually, if we're talking about functional programming you should ideally be using arrow functions as they don't bind this, therefore they're better suited for functional programmng.

Thread Thread
 
damcosset profile image
Damien Cosset

I am not sure that using this in functional programming is recommended. If you don't need to bind this, it means that you need to access the outer this scope right? Therefore, this function is not pure anymore and doesn't solely rely on its arguments. Or am I not understanding something ?

There is also the problem of readability with arrow functions. The syntax is shorter, no doubt, but functions are anonymous. It might not always be useful to trade readability for shorter code.

Thread Thread
 
pamblam profile image
Rob Parham

Exactly. Anything that binds "this" is oop, not functional. Arrow functions do not, so they're better suited for truly functional programming.

Collapse
 
tiffany profile image
tiff

None of what you have said here really matters. I'm making a point, syntax aside. If you want to play around with some code, I suggest you find the code that is syntactically more pleasing to you, as I won't change this. I also don't really need to explain myself.