Can't Use "+=" in Chrome Console?!?!


Why’s this happening, please?

I know you can’t do document.write() in the console so is this case a similar situation??


 > a = 5
   b = 1
<- undefined
 > a
<- 6


There’s not really a why to that, what you wrote doesn’t make sense, it’s a case of “why would you be able to?”, much like why a rock on your kitchen table doesn’t dance. The second version isn’t any better.
Entirely unrelated to chrome.

Argue for what you’re doing and why it would be written that way instead.


Also, note that we cannot augment a variable that is just being declared/defined.


Okay, thanks, LOL – you have can be very circumspect in the way you say things sometimes…just like a language parser!!


Yes, I finally saw what I did there…boy these error messages are really less than helpful: instead of alerting me that my logic was wrong, it sent me off in a totally wrong direction, making me think my syntax was wrong!!

Why do the parsers do that?? Why not just say “something doesn’t make sense here” instead???


What do you mean by “augment”…I understand the everyday English but not in a JavaScript context.


To augment means to increase. += is an augmentation assignment that requires the object on the left to be a defined value that matches the type of the assignment on the right. undefined cannot be added to a number.


Ah, you mean “increment” – is “augment” really a term in JavaScript? Just curious. I just did a quick Google search for “augment javascript” but still ain’t sure.

But okay, thanks, so we can’t declare a variable and then in the same expression or statement an operation on it. Got it!

increment => add 1
augment   => increase by any amount

It’s a word in the English language which means to increase. In JS this could be by addition, multiplication or exponentiation, or in the case of strings, by concatenation.

Language is meant to make us think. If you want everything spelled out for you like ducks in a row, then you are dreaming. Don’t forget to turn on your thinking cap so the language being communicated is assimilated into learning. Do forget the jargon and petty bothers. Get to work coding and completing lessons. It will all unfold eventually.


Heehee…I see…no wonder you’re so good at this!

Thanks; good point. Though the problem I have with computer programming is that, in a very real sense, I gotta put on a significantly dumbed-down sort of thinking cap – and I don’t know which “size” to use, how dumbed-down the thinking cap must be!

So right now I’m too human for a computer and becoming sometimes too computer-like for humans!


In Taoism there is an expression, the minute you think you have your finger on it, it moves (paraphrase). We can know a thing very well but there is still something to learn about it. Just like in sports, we develop our natural ability through ‘reps’. Eventually we are able to branch out and take on greater challenges. With each new challenge we cannot help but discover something new about the concept, and also about ourselves.


This confirms what we spoke of earlier…

>>> s = c = 0
>>> s, c += 2, 1
SyntaxError: illegal expression for augmented assignment


Indeed – but I think that they were specifically referring to the dynamic ever-changing nature of this universe, not “simply” that there’s more to know about something even when we think we already know…

Certainly, and for me learning programming is just a stepping stone towards getting into the physical sciences and, eventually, mathematics…I’m 45 and have spent most of my life researching philosophy, history, psychology (including art and literature) and now, having at long last satisfied myself fairly well enough with MVP (Minimum Viable Product)-type of answers to questions concerning The Eternal Verities, I’m finally ready to pursue more “left-brain” stuff!

So thanks for all your assistance on my new journey!



Thanks for that. Don’t know why googling “augment javascript” didn’t turn up anything – but maybe it’s a general computer science term…though syntax error messages are not exactly known for their semantics!!


For the record, that is a syntax error in another language (Python) but describes it beautifully since there are two parts to the expression.

    a = a + 2
      ^ -----  augment a
    assign to a

    =>  a += 2


Oh, well, thanks for fully annotating the record and correcting my misunderstanding, then!

So there is no “augment” in JavaScript, just as my fruitless googling had suggested. Though I certainly concede the point that this is a general computer science word…well, I’m working on learning general CompSci – but first I’ve got to figure out me JS basics!! o_0


Start with separating the human language from the jargon. That will make things easier.


Yes, indeed – hence my previous frustration at knowing which “size” of “dumbed-down” thinking cap to use!

Sometimes I’m too “literal-minded” for a high-level language like JavaScript, and other times I’m too" broad-minded" for what is still computerese, after all!

Something of a case in point would be my latest question on these forums at Different Switch Statement "Initial Evaluations" – just for an example… :wink:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.