Last active
January 22, 2017 08:18
-
-
Save borisd/05c09d853fdbdd2bbe85dd948d10440e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const greet = ({ name = 'Me' }) => console.log(`Hi ${ name }`); | |
const repeat = (name, count = 0) => { | |
if (count) { | |
setTimeout(() => greet({ name }), 1000 * count); | |
repeat(`${ name }.`, count - 1); | |
} | |
}; | |
repeat('Boris', 10); |
This file contains hidden or 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
const user = { | |
name: 'Boris', | |
images: { | |
thumb: 'image' | |
} | |
}; | |
function getImage(user, type) { | |
var images = user && user.images || {}; | |
var thumb = images && images[type] || 'none'; | |
console.log(thumb); | |
} | |
getImage(user, 'thumb'); | |
getImage(user, 'full'); | |
getImage({ }, 'thumb'); | |
getImage({ images: {} }, 'thumb'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment