Expressions
We usually call +
, -
% of mathematical operators , *
, <
, >
of conditional operators , or
A set of values, permeated by operators, is what we call "expression", and an expression returns a value.
The "Conditional Expression"
The condition is nothing special, because as it says, ==
is just an operator. And and
simply uses its result to define what it will do.
When you say:
if (x > y) { ...
You are first calculating the value of or
. Let's suppose that by chance &&
actually is greater than ||
, the result of this "calculation" will be >
, so it would have the same effect as if it were written if
in that particular case.
Likewise, x > y
is equivalent to:
var meu_teste = x > y; // teste recebe o valor true se x > y
if ( meu_teste ) { ...
Only after "calculated" will the value of x
that y
will use the returned result. In fact, true
"does not even know, does not care" about what happened inside the parentheses.
The "Boolean Expression" 1
Likewise, if (true)
and if (x > y)
could also be saved in var ";)
var condicoes = true or false; // true || false, etc.
if ( condicoes ) { ...
At a glance: you're just saving a value from an operation like any other. As x > y
, operations if
, if
and or
return a value at the end.
1. I am not sure what I want to do, but I do not know how to do it.