Expressões e operadores
Expressões
Option 1:
const fahrenheit = 50;
const celsius = fahrenheit - 32 / 1.8;
console.log(celsius); //=> 32.2const fahrenheit = 50;
const celsius = fahrenheit - 32 / 1.8;
console.log(celsius); //=> 32.2Option 2 (grouping operator):
const fahrenheit = 50;
const celsius = (fahrenheit - 32) / 1.8;
console.log(celsisu); //=> 10const fahrenheit = 50;
const celsius = (fahrenheit - 32) / 1.8;
console.log(celsisu); //=> 10References:
Operadores
| Operator type | Operators |
|---|---|
| Primary expressions | this, function, class, function*, yield, yield*, async function*, await, [], {}, /ab+c/i, ( ) |
| Left-hand-side expressions | object.property, object["property"], new, new.target, super, ...obj |
| Increment and decrement | A++, A--, ++A, --A |
| Unary operators | delete, void, typeof, +, -, ~, ! |
| Arithmetic operators | +, -, *, /, %, ** |
| Relational operators | in, instanceof, <, <=, >, >= |
| Equality operators | ==, !=, ===, !== |
| Bitwise shift operators | <<, >>, >>> |
| Binary bitwise operators | &, |, ^ |
| Binary logical operators | &&, || |
| Assignment operators | =, *=, /=, %=, +=, -=, <<=, >>=, >>>=, &=, ^=, |=, [a, b] = [1, 2], {a, b} = {a:1, b:2} |
| Conditional operator | (condition ? ifTrue : ifFalse) |
| Comma operator | , |
Referências: