87 lines
1.8 KiB
JavaScript

"use strict";
const david = {
firstName: "David",
lastName: "Aster",
age: 36,
};
const { firstName, lastName, age } = david;
console.log(firstName, lastName, age);
const restauraunt = {
name: "Classico Italiano",
location: "Via Angelo Tavanti 23, Firenze, Italy",
categories: ["Italian", "Pizzeria", "Vegetarian", "Organic"],
starterMenu: ["Focaccia", "Bruschetta", "Garlic Bread", "Caprese Salad"],
mainMenu: ["Pizza", "Pasta", "Risotto"],
order: function (starterIndex, mainIndex) {
return [this.starterMenu[starterIndex], this.mainMenu[mainIndex]];
},
orderDelivery: function ({
starterIndex = 1,
mainIndex = 0,
time = "20:00",
address,
}) {
console.log(
`Order recieved! ${this.starterMenu[starterIndex]} and ${this.mainMenu[mainIndex]} will be delivered to ${address} at ${time}`
);
},
openingHours: {
thu: {
open: 12,
close: 22,
},
fri: {
open: 11,
close: 23,
},
sat: {
open: 0, // Open 24 hours
close: 24,
},
},
};
restauraunt.orderDelivery({
time: "22:30",
address: "Via del Sole, 21",
mainIndex: 2,
starterIndex: 2,
});
restauraunt.orderDelivery({
address: "Via del Sole, 21",
starterIndex: 2,
});
let { name, categories, openingHours } = restauraunt;
console.log(name, categories, openingHours);
const {
name: restaurauntName,
categories: restaurauntCategories,
openingHours: restaurauntOpeningHours,
} = restauraunt;
console.log(restaurauntName, restaurauntCategories, restaurauntOpeningHours);
const { menu = [], starterMenu: starters = [] } = restauraunt;
console.log(menu, starters);
let a = 111;
let b = 999;
const obj = { a: 1, b: 2, c: 3 };
({ a, b } = obj);
console.log(a, b);
const {
fri: { open: o, close: c },
} = openingHours;
console.log(o, c);