Expression
An expression is a piece of source code that produces a value at runtime.
Related concepts: EvaluationValue
Closest Wikipedia entry: Expression (computer science) — In computer science, an expression is a syntactic entity in a programming language that may be evaluated to determine its value. It is a combination of one or more constants, variables, functions, and operators that the programming language interprets (according to its particular rules of precedence and of association) and computes to produce ("to return", in a stateful environment) another value. This process, for mathematical expressions, is called evaluation.
Misconceptions about Expression51 documented Misconceptions
Check YourselfArithmeticPlusPrecedes — Java
Addition has higher precedence than string concatenationArrowFunctionNoImpliedReturn — JavaScript
Even when an arrow function consists just of an expression, the return keyword must be explicitly writtenArrowFunctionRequiresFunctionKeyword — JavaScript
Arrow functions also require the keyword 'function'AssignCompares — Java
= compares two valuesAssignCompares — Python
= compares two valuesAssignmentNotExpression — Java
An assignment a=b is not an expressionCannotChainAttributeToObjectInstantiation — Python
Method calls, and attribute accesses in general, cannot be chained to a constructor invocation.CannotChainMemberAccesses — Java
Member accesses cannot be chained togetherCannotChainMemberToConstructor — Java
Method calls or field accesses cannot be chained to a constructor invocationChainedMethodsNotCalledFromOutside — Java
Chained methods are all called on the object at the beginning of the chainCompareBooleanToConstant — Scratch
To test whether an expression evaluates to true or false, one must compare it to a constantComparisonWithBoolLiteral — Python
To test whether an expression is True or False, one must compare it to True or to FalseComparisonWithBooleanLiteral — Java
To test whether an expression is true or false, one must compare it to true or to falseCompositeExpressionsUntyped — Java
Expressions that consist of multiple parts have no typeConditionalOperatorNotExpression — JavaScript
The conditional operator is not an expressionEqualityOperatorComparesListIdentities — Scratch
(list a) = (list b) compares the identities of list a and list bEqualityOperatorComparesObjectsValues — Java
o==p compares the objects referred to by variables o and pEqualsComparesReferences — Java
o.equals(p) compares the references stored in the variables o and pExpressionAssigns — Java
An expression that reads a variable also updates its value after the evaluationExpressionAssigns — Scratch
An expression that reads a variable also updates its value after the evaluationExpressionsDynamicallyTyped — Java
One has to evaluate an expression to determine its typeIdentifierAsStringInBracketNotation — JavaScript
An identifier used to access a property with the bracket notation is treated as a stringInlineCallInExpressionTree — Java
The expression tree of an expression involving a call inlines the call's computation of the returned valueInlineVariableInExpressionTree — Java
The expression tree of an expression involving a variable inlines the variable's definitionLargeIntegerLong — Java
Large integer numbers have type longLiteralNoExpression — Java
A literal is not an expressionMandatoryAssignment — JavaScript
An expression must be assigned to have a valid statementMapToBooleanWithConditionalOperator — Java
To map a boolean expression to a boolean, a conditional operator is necessaryMapToBooleanWithTernaryOperator — Python
To map a boolean expression to a bool, a ternary conditional operator is necessaryNoAtomicExpression — Java
Expressions must consist of more than one pieceNoAtomicExpression — JavaScript
Expressions must consist of more than one pieceNoAtomicExpression — Python
Expressions must consist of more than one pieceNoFunctionCallsChaining — JavaScript
It is not allowed to chain function callsNoShortCircuit — Java
&& and || always evaluate both operandsNoShortCircuit — Python
and/or always evaluate both operandsObjectsMustBeNamed — Java
A variable is needed to instantiate an objectObjectsMustBeNamed — Python
A variable is needed to instantiate an objectOutsideInFunctionNesting — Python
Nested function calls are invoked outside inOutsideInMethodNesting — Java
Nested method calls are invoked outside inParenthesesOnlyIfArgument — Java
() are optional for method calls without argumentsParenthesesOnlyIfArgument — Python
() are optional for function calls without argumentsPlusConcatenatesNumbers — Python
The plus operator can concatenate strings and numbersRightToLeftChaining — Java
Chained accesses are invoked from right to leftRightToLeftChaining — Python
Chained accesses are invoked from right to leftSelfNoExpression — Python
The name self is not an expressionStringPlusStringifiesExpression — Java
String concatenation stringifies non-String operand expressionsTargetTyping — Java
The type of a numerical expression depends on the type expected by the surrounding contextThisChildInCallExpression — Java
Instance method or constructor call nodes in expression trees have a child labeled "this"ThisNoExpression — Java
The name this is not an expressionVariablesHoldExpressions — Java
= stores an expression in a variableVariablesHoldExpressions — Python
= stores an expression: it stores a reference to the expression in a variable