Created
February 21, 2020 09:18
-
-
Save vladilenm/3b6df3316301236c3334b5b9fb34a888 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function calcValues(a, b) { | |
return [ | |
a + b, | |
a - b, | |
a * b, | |
a / b | |
] | |
} | |
const [sum, sub = 'Вычитания нет', mult, ...other] = calcValues(42, 10) | |
// const sum = result[0] | |
// const sub = result[1] | |
// const [sum, sub] = result | |
console.log(sum, mult, other, sub) | |
// Objects | |
const person = { | |
name: 'Max', | |
age: 20, | |
address: { | |
country: 'Russia', | |
city: 'Moscow' | |
} | |
} | |
// const name = person.name | |
const { | |
name: firstName = 'Без имени', | |
age, | |
car = 'Машины нет', | |
address: {city: homeTown, country} | |
} = person | |
// const {name, ...info} = person | |
// console.log(name, info) | |
function logPerson({name: firstName = '111', age}) { | |
console.log(firstName + ' ' + age) | |
} | |
logPerson(person) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment