0 // 0
1 + 1 // 2
'Hello' + ' ' + 'World' // 'Hello World'
{ answer: 42 } // { answer: 42 }
Object.assign({}, { answer: 42 }) // { answer: 42 }
answer !== 42 ? 42 : answer // 42
answer = 42 // 42
const plantNeedsWater = function(day){
if (day === 'Wednesday'){
return true;
} else{
return false;
}
}
console.log(plantNeedsWater('Tuesday'))
const mul = function(x, y){
return x * y;
}; //semicolon needs to be there as it is expression
console.log(mul(10, 20));
// EXPRESSION: Code that produces a value
// example(s):
3 + 4
1991
true && false && false
// STATEMENT: Code that performs actions (generally something that ends in ";"
// example:
const str = `String assigned to str`;
5; // Baris kode ini merupakan expression karena interpreter akan membaca kode ini dan menghasilkan nilai 5.
2 + 3; // Baris kode ini juga merupakan expression. Interpreter mengevaluasi kode dan juga akan menghasilkan nilai 5.