Video 56: ES6 Aside: Default Function Parameters
This commit is contained in:
parent
040916eaa2
commit
4fc267d599
@ -29,7 +29,7 @@ const product = {
|
||||
// console.log(stock)
|
||||
// console.log(rating)
|
||||
|
||||
const transaction = (type, {label, stock}) => {
|
||||
const transaction = (type, { label, stock = 0 } = {}) => {
|
||||
console.log(type, label, stock)
|
||||
}
|
||||
|
||||
|
7
playground/7-default-params.js
Normal file
7
playground/7-default-params.js
Normal file
@ -0,0 +1,7 @@
|
||||
const greeter = (name = 'user', age) => {
|
||||
console.log('Hello ' + name)
|
||||
}
|
||||
|
||||
greeter('Jason')
|
||||
|
||||
greeter()
|
@ -48,7 +48,7 @@ app.get('/weather', (req, res) => {
|
||||
})
|
||||
}
|
||||
|
||||
geocode(req.query.address, (error, {latitude, longitude, location}) => {
|
||||
geocode(req.query.address, (error, {latitude, longitude, location} = {}) => {
|
||||
if (error) {
|
||||
return res.send({ error: error })
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user