Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
TrayKnots6111dJs/Ts?
Benefit: no .bind(this) required. Behave as expected.
But honestly, readability is a function of how much you're used to something. Nothing else.
Readability arguments are bullshit by design, because the readability gauge is always biased. -
b2plane614111dThis is literally what i was fucking mad about in the beginning but i found out react is a completely different mindset shift (C++ like) than OOP such as angular
This is why arrow functions in procedural programming (react) is used while in OOP a function syntax is used -
Demolishun3107111d@Lensflare no, I think JS functions are objects to begin with. You can assign functions to variables.
-
jestdotty252211dI know if you take functions out of a class and assign them to something else they'll forget what class they came from so you have to bind them to an instance and that's annoying
I don't know if a random function and a lambda have a difference. they probably do
I always view lambdas as more lightweight, also less typing. so I favour them. they also have less weird side effects that might be difficult to anticipate
but the fact we have the stupid export syntax now I guess invalidates that -
Demolishun3107111d@jestdotty I think C++ does that too. I seem to remember that calling a function on a class actually inserts the first parameter as "this". It is hidden. But if you call the function explicitly you can provide the first parameter to a class instance to make the call. At least that is my memory. It might be faulty.
-
Lensflare1415311d@Demolishun that’s what I was thinking too. Other languages do it like that too. But js is, as we all know, special.
-
Demolishun3107111d@Lensflare not sure about JS (probably), but in Python I could create variables on a function object. I actually used that feature to join Python to a game engine that had calls from another scripting language. I needed the python function to be aware of the class the call came from. So I stored the class in a variable on the function itself from the C++ side. I cannot remember exactly how the implementation worked in my mind though.
-
i use allow functions whenever the method body is trivial enough to be expressed in one single line without overcomplicating things.
Related Rants
Why shall I convert my utility functions into arrow functions?? I really don't see the point.
I think it is way more descriptive to read a line going
"export function buildEntity(){"
Instead of
"export const buildEntity = () => {"
When are you using arrow functions? Do you see any benefits there?
rant
js
react