hello2jolee / react-movie-pro

0 stars 0 forks source link

FUNDAMENTALS #1

Open hello2jolee opened 3 years ago

hello2jolee commented 3 years ago

Object Destructuring

const human = {
  name: "JO",
  lastName: "Lee",
  nationality: "Korean",
  favFood: {
    breakfast: "삼겹살",
    lunch: "돈까스",
    dinner: "삼겹살 + 돈까스"
  }
}

// const name = human.name
// const lastName = human.lastName
const { 
  name, 
  lastName, 
  nationality: difName, 
  favFood: { dinner, breakfast, lunch } 
} = human

console.log(name, lastName, difName, dinner) // output : JO LEE Korean 삼겹살 + 돈까스
hello2jolee commented 3 years ago

Spread Operator

const days = ["MON", "TUES", "WED"]
const otherDays = ["THU", "FRI", "SAT", "SUN"]

const allDays = [...days, ...otherDays]

console.log(allDays) // output : ["MON", "TUES", "WED", "THU", "FRI", "SAT", "SUN"]
const ob = {
  first: "hi",
  second: "hello",
}

const ab = {
  third: "bye bye"
}

const two = { ...ob, ...ab }

console.log(two) // output : Object {first: "hi", second: "hello", third: "bye bye"}