What are "expressions" in javascript?

Asked

Viewed 23 times

0

I would like to know what are "expressions" and "primary expressions" in javascript. The Mozilla as an example of expression x = 7 and 3 + 4, but in the "primary expressions" part it shows the "this" which is a reserved word and has nothing to do with x = 7 or 3 + 4 and shows the "()" (cluster operator). If possible also explain what is "left side expression" that is also displayed on the website.

  • 1

    The question marked as duplicate already answers what is an expression, but only to complete in relation to this - think about expression as all that returns a value when it is evaluated. Thus, the this (as any other variable), when it is "read" by Runtime, will return the value of Binding. The this is nothing more than a variable, considered "special" because it is always implicit in the execution context.

  • 1

    in the link itself explains "An expression consists of any valid unit of code that is solved as a value", that is, something that solved generates a value, can assign or not to a variable this value, as the examples that put x = 7 the value is 7, assigned to x and here 3 + 4 the value is 7 but has not been assigned, probably will be used as part of a larger expression, for example if (y == 3+ 4) or if (y > 3 + 4), etc. The link is very detailed, perhaps missing an example of expression on the left, as x += 2 or calculates x+2 and assigns to the left the same as x = x + 2

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.