Skip to content

Instantly share code, notes, and snippets.

@hustKiwi
Last active September 21, 2019 09:18
Show Gist options
  • Save hustKiwi/566d82c6da1052d3c9a616f0e831c73c to your computer and use it in GitHub Desktop.
Save hustKiwi/566d82c6da1052d3c9a616f0e831c73c to your computer and use it in GitHub Desktop.
// Arithmetic operators and Assignment
let x = 1;
let y = 2;
x += y;
console.log(x);
x = y++;
console.log(x);
console.log(y);
x = ++y;
console.log(x);
console.log(y);
// Spread and destructuring
const a = [1, 2, 3, 4, 5];
const b = [...a, 6];
console.log(b);
const car = { wheel: 4 };
const bigCar = { ...car, size: 'large' };
console.log(bigCar);
const c = [1, 2, 3];
const [c1, c2, c3] = c;
console.log(c3);
const obj = {
a: 1,
b: 2,
c: 3
};
const { b, c } = obj;
console.log(b, c);
// Comparision
console.log(1 == '1');
console.log(1 === '1');
const a = {};
const b = {};
console.log(a == b);
console.log(a === b);
// Conditional operators
const age = 2;
console.log(age >= 18 ? 'adult' : 'non-adult');
console.log(age >= 18 && 'adult' || 'non-adult');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment