Skip to content

Tag: syntax

The difference in syntax for updating an object item

What is the difference between: and Answer The first is an assignment to cartItem, while the second is a mutation of the object held by cartItem. The first creates a new object. The previous value of cartItem referenced an object that could still be referenced by another reference. Demo: So there is a differe…

Use of commas versus semicolons?

Given the following code: As can be seen, there is a mix of both. What would be the benefit of using one or the other? My understanding is that the semicolon is to end the statement. And comma should be used to string together multiple declarations. So is it safe to say that with this example then there shoul…

Parse indentation level with PEG.js

I have essentially the same question as PEG for Python style indentation, but I’d like to get a little more direction regarding this answer. The answer successfully generates an array of strings that are each line of input with ‘INDENT’ and ‘DEDENT’ between lines. It seems like h…