3 ms·
Exactly, and this is a big problem where I work. I believe code should be readable, even by those with only cursory knowledge of the language. Object shortcuts
by i__believe 10y ago
Exactly, and this is a big problem where I work. I believe code should be readable, even by those with only cursory knowledge of the language. Object shortcuts is also a problem I think. For example, I had a method like this:
const getObj = (id, store) => {
return {
id: id
name: store.something.name
};
};
The linter gave an error on it because I used {id: id}. It was like the linter was trying to make my code harder to read.
I think es6 in the wrong hands quickly falls prey to the problems of ruby/scala where it can become incredibly terse and hard to parse unless you are used to the author's particular style.
- gidan 10y agoYou know instead of: const getObj = (id, store) => { return { id } } You could write: const getObj = (id, store) => ({ id })
- i__believe 10y agoI'm pretty sure that's a good illustration of my point.
- dwaltrip 10y agoThis is a matter of personal preference. I find `return` to be quite distracting and annoying for a small function that spans part of a line, while you and some others may prefer the explicitness of the `return` keyword. I would agree that nested destructuring should be used quite cautiously. Code legibility is incredibly important to the success of any serious project.