6 ms·
// And a `tokens` array for pushing our tokens to. var tokens = []; // We're going to create a `value` string that we are going to push // characters
by herbst 11y ago
// And a `tokens` array for pushing our tokens to.
var tokens = [];
// We're going to create a `value` string that we are going to push
// characters to.
var value = '';
Sure OP tried to be super descriptive but there a few comments that you simply don't need at all with at least nice a little understanding.
- rukai 11y agoI am someone who doesnt know much about compilers and I found them helpful. Setting up each variables purpose builds up context in my mind lessening the struggle with the 'real' code.
- herbst 11y agoOP did a very good job at explaining. My point is rather that, while some circlejerk about how important comments are, this is not a good example how they should be done in a professional environment. In a pure learny way it's really well done. Personally i find the comments distracting.
- thejameskyle 11y agoAuthor here. I actually walked through all of this code line by line in a conference talk using another thing I built: https://github.com/thejameskyle/spectacle-code-slide https://github.com/thejameskyle/spectacle-code-slide I ripped these code comments from my presenter notes where I was explaining everything in case people couldn't read it. I'll have to go back in and clean it up
- abiox 11y agosome people get really weird about comments. in a case like this, i actually like the dialogue/conversation nature of the comments. i think the opinion of "not needing them" seems miss what they're accomplishing.
- javajosh 11y agoComments about intention are good. Yes, an experienced dev can infer intent from context (name, project, 'culture'), and even a smart beginner can read ahead to infer intent. But the comment resolves ambiguity in the advanced dev's mind, and saves the beginner's mind from the difficulty of read-ahead inferences (of which he may have several going at once). I say, keep it.
- eveningcoffee 11y agoPlease DO NOT. You are right in your other comment that it helps with the flow and for example in the case of // We're going to create a `value` string that we are going to push // characters to. var value = ''; your comment declares you intention in advance, even if it might be trivial to deduce.