Repository navigation
Others
sergio edited this page Nov 8, 2020
·
10 revisions
NOTE how for
Objectswe useconst {}and for arraysconst []
const doggie = {
first: 'Buzz',
breed: 'Great Pyrenees',
fur_color: 'black and white',
activity_level: 'sloth-like',
favorite_food: 'hot_dogs'
};
const { first, breed } = doggie;and with arrays:
const dogs = ['Great Pyrenees', 'Pug', 'Bull Mastiff']
const [medium, small, giant] = dogs
console.log(medium, small, giant) // Great Pyrenees, Pug, Bull Mastiff
const [, small, giant] = dogs
console.log(small, giant) // Pug, Bull Mastifffunction muppetLab(a, b, ...muppets) {
console.log(a, ' ', b); // Dr. Bunson Beaker
console.log(muppets); // ["Miss Piggy", "Kermit", "Animal"]
console.log(muppets[0]); // Miss Piggy
console.log(muppets.length); // 3
}
muppetLab("Dr. Bunson", "Beaker", "Miss Piggy", "Kermit", "Animal")