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

>Having less characters makes code more readable (or rather "scannable") as well, it's just another tradeoff.

Only to a point, otherwise minified js would be more legible than plain source. It takes "a couple of seconds" to scan the codebase and find out what el or ev refer to, but it would take zero seconds if they were just called "event" or "element."[0] There's no gain in readability from shaving off one or two characters in that case. It just "feels" more efficient because it resembles the common style of lower level code.

[0]Assuming those aren't reserved words in javascript, I don't know.




Of course, up to a point. The same goes for very long but extremely descriptive variable names. Hence, it is a tradeoff.


You are allowed to use both event and element, as they aren't strictly reserved keywords.

I think it's generally frowned upon, though. For example, I believe "event" is defined as a global in browsers (on window, perhaps?), so you run the risk of shadowed variables and accidentally referring to the wrong thing.




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

Search: