The problem

In JSX syntax, you can place any valid JavaScript expression inside curly braces. What types of descriptions are correct?

[] arithmetic, mainly using “arithmetic operators” to calculate the result of the expression as a number;

[] logic, mainly with the “logical operator” to calculate the result is true or false value of the expression;

[] Expression on the right: expression used to assign a value to the target;

[] string, mainly using “string operator” to calculate the result as a string expression;

The answer

A, B, D

answer

We follow the following definition to understand the concept of an expression.

An expression is any valid unit of code that resolves to a value.

JavaScript has the following expression classes:

  • Arithmetic: The result is a number, such as 3.14159. (Arithmetic operators are usually used.)
  • String: The computed result is a string, such as “Fred” or “234”. (String operators are usually used.)
  • Logic: Evaluates as true or false. (Usually logical operators are involved.)
  • Primary expressions: Basic keywords and generic expressions in JavaScript.
  • Left-hand expression: The left-hand value is the target of assignment.

The first three are easy to understand, mainly the last two brief explanation. General expressions can be simply divided into object introductions and operation groups, while the expression on the left can be understood as all assignment scenarios.

Object lead-in representations are used with dot or parenthesis objects.

this['propertyName']
this.propertyName
this.methodName()
Copy the code

The grouping operator () controls the priority evaluated in the expression. For example, you can cover multiplication and division first, and then addition and subtraction to calculate addition first.

(a + b) * c   // 9
Copy the code

Left-hand Side (LHS) expression based on Reference type.

a.b = c;
Copy the code

data

Expressions, Statements and Structures

LHS query or RHS query? The compiler says something

Mozilla – Expressions_and_Operators

source

Search “Test competition” micro channel mini program