Skip to content

Instantly share code, notes, and snippets.

@iamsaief
Created August 22, 2020 12:09
Show Gist options
  • Save iamsaief/0e810812f1ce2f1e6728abaafd20709a to your computer and use it in GitHub Desktop.
Save iamsaief/0e810812f1ce2f1e6728abaafd20709a to your computer and use it in GitHub Desktop.
/* 3 dots: spread */
const red = ["🧑"];
const green = ["πŸ’š"];
const blue = ["πŸ’™"];
const rgbHeart = [...red, ...green, ...blue];
console.log(rgbHeart);
// Output : ["🧑", "πŸ’š", "πŸ’™"]
/* destructure: array */
const hearts = ["🧑", "πŸ’š", "πŸ’™", "πŸ’›", "πŸ’œ", "πŸ–€", "🀍"];
const [r, g, b] = [...hearts];
console.log(r, g, b);
// Output : 🧑 πŸ’š πŸ’™
/* destructure: object */
const userInfo = {
id: 101,
username: "jdoe",
name: "Jhon Paul Doe",
age: 33,
phone: "0123456789",
};
const { name, phone } = { ...userInfo };
console.log(name, phone);
// Output: Jhon Paul Doe 0123456789
/* Finding min/max */
const numArr = [200, 300, 400, 500, 600];
const min = Math.min(...numArr);
const max = Math.max(...numArr);
console.log(min, max);
// Output: 200 600
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment