4 ms·
Javascript and semicolon insertion
- orangecat 16y agoA horrible Javascript misfeature, second only to default global scope. I always use semicolons, but as the article notes even if you do that you still have to be aware of how automatic insertion works.
- deleted 16y ago[deleted]
- notauser 16y agoFrom the article, the only really nasty things are: [a].forEach(fn(){}) [b].forEach(fn(){}) // Parses as [a][b] return a+b // Parses as return; You would have to work pretty hard to trigger the rest. I'm curious about the speed trade offs from removing semicolons. You shrink the source code a little, but does the parser throwing exceptions all the time bump up execution time?
- barrkel 16y agoA parser would not normally handle this kind of thing with exceptions, and any cost would only be paid once, at parse time when building a syntax tree, not at execution time. Very few languages interpret text directly, rather than interpreting trees, as the trees are far easier to work with, more efficient, etc.
- mkramlich 16y agothis issue and the 'var' keyword are two of the reasons I feel Python is mostly a superior language. (Not necessarily completely, just overall.)
- pdx 16y agoEvery since I started using JSMin, I've needed to add semicolons after all my functions, which is something that I can't seem to remember to do as a habit.
- cmelbye 16y agoFrames? Is it the 90s again?
- inimino 16y agoNo, there are no frames.
- mdaniel 16y agoI realize this is not the forum for this, but hopefully it will serve as a warning to others: the linked article does not scroll on the iPhone (horiz or vert orientation). "Cool" layouts are all fun and games, but usability is king.
- noblethrasher 16y agoIt does but you have to use two fingers.
- frofro 16y agoYup, I only learned about this feature a few months ago. It also makes other apps like the standard Google Reader usable.
- inimino 16y agoIt seems to be an issue with the iPhone and iPad. Hopefully Apple will fix it, as I'm sure there are other sites with scrollable areas within a page. If not, I'll probably find a workaround eventually.
- tszming 16y agoUse JSLint: http://www.jslint.com http://www.jslint.com
- bugmenot 16y agoGoogle Go language has almost the misfeature.