4 ms·
This would be an entertaining comment when read by a C programmer: // Overly clever way of saying: increment `currentChunk` then use the incremented value
by defined 9y ago
This would be an entertaining comment when read by a C programmer:
// Overly clever way of saying: increment `currentChunk` then use the incremented value
this.chunks[++currentChunk] = []
Pre- and post-increment operators are bread and butter in C, hardly overly clever. Are they a recent addition to JS?
- nikkwong 9y agoNope.. They've been in JS since the early versions of emcascript. JS is often used for more web-appy stuff than actual math so I wouldn't say they're used very abundantly, which may explain the comment.
- Kiro 9y agoNot only when read by a C programmer. I'm a JS programmer and I don't understand what's "overly clever" about something you learn in JS 101.
- barryhoodlum 9y agoOn top of that, he could have just written "currentChunk++;" and skipped the comment entirely.
- J-dawg 9y agowouldn't that return the value of currentChunk before it was incremented? So it would need an additional line to be equivalent to the example (making it a bit more readable in my opinion): currentChunk++; this.chunks[currentChunk] = []; Which is perhaps what you meant all along. Please excuse the pedantry.
- barryhoodlum 9y agoYeah, that's what I meant - instead of taking the shortcut with a comment explaining it, just don't take it in the first place.