Quick actions

cmd+k|ctrl+k

Navigation

Languages

Assigment Operator

Snippet info

Language

JavaScript

Visibility

public

Author

wiriawan18

Created

2020-07-26T14:36:58Z

Updated

2020-07-26T14:38:56Z

let x = 10;
let y = 5
 
x += y; // artinya -> x = x + y;
x -= y; // artinya -> x = x - y;
x *= y; // artinya -> x = x * y;
x /= y; // artinya -> x = x / y;
x %= y; // artinya -> x = x % y;
 
console.log(x);

const aString = '10';
const aNumber = 10
 
console.log(aString == aNumber) // true, karena nilainya sama-sama 10
console.log(aString === aNumber) // false, karena walaupun nilainya sama, tetapi tipe datanya berbeda
 
/* output
true
false
*/


let a = 10;
let b = 12;
 
/* AND operator */
console.log(a < 15 && b > 10); // (true && true) -> true
console.log(a > 15 && b > 10); // (false && true) -> false
 
/* OR operator */
console.log(a < 15 || b > 10); // (true || true) -> true
console.log(a > 15 || b > 10); // (false || true) -> true
 
/* NOT operator */
console.log(!(a < 15)); // !(true) -> false
console.log(!(a < 15 && b > 10)); // !(true && true) -> !(true) -> false
 
/* output
true
false
true
true
false
false
*/
INFO