My colleague approached me the other day with a line of JavaScript code he had found on Stack Overflow, and asked how it worked. And I thought it w...
For further actions, you may consider blocking this person and/or reporting abuse
This is all very funny and cool, but it's bad code because it's hard to read. Good code - no need to document. One glance at the names of the variables makes it clear what should be there and what to do with it. Immediately you need to read it, and more than once. But overall, yes. Very brief and succinct.
Absolutely. I think that these kinds of functions can be okay in a contained context so that anything using it will call a method with a well understood name, the implementation details are not important for the calling context.
Actually it is not so unreadable but it is very useful to repack object. I would split only to arrow function pickUp and use that in the next line. This way it is readable and useful. I know there is such a example with pickAC function.
The longer you code the more you appreciate simplicity of a code you see. Cause you don't have a time for such trickery - it only matter how much you ship. Code should be «good enough to read by someone else without explanation», not a nomination for a hackathon «hall of fame».
Also a typo with myfunction and myFunction in the later snippets 😉
Interesting refresher of some concepts!
Thank you! Greatly appreciate these corrections!
Might have meant "arrow function" instead of "array function". "To each their own" - can't agree more :)
Thank you so much! Didn't spend as much time on proof reading this one as I usually do! :)
I can relate
Did it work with var in place of const ?
Should work, but I would stay with const.
To be fair, you can write unintelligable code in almost any language. But yes, this line is not that great, thus this article :)
Thank you for this clean and clear concepts. I am just a beginner in javascript language and your explanation is very useful. I wlll keep it for my future references.
Glad to hear!
No one ever will use this :)