Hacker News new | past | comments | ask | show | jobs | submit login

> I think the = being so removed from what it's actually assigning, but without grouping parens, is what messes me up.

I almost always use grouping parentheses for this reason, unless it’s a very short single line expression. That said, if/else if/else has a different colocation problem: it puts the assignment further from the initial declaration, making its scope less obvious (unless you’re hoisting var, which is awful for its own reasons).




Agree, the problem with if/else is that you end up having to consider the whole block plus usually a little context from just before it. I still find it much easier to read, unless very poorly written, while all ternaries slow me down every single time I read one, no matter how well-written. I struggle to parse them into ideas and words and to follow the order of events, seemingly no matter how many times I encounter them. They just feel wrong. All that implicit scoping crammed into one line, relying on memory and active searching to find the boundaries and then follow the order of events back "to the top", rather than having them explicitly marked.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: