Skip to content

Instantly share code, notes, and snippets.

@borisd
Last active January 22, 2017 08:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save borisd/05c09d853fdbdd2bbe85dd948d10440e to your computer and use it in GitHub Desktop.
Save borisd/05c09d853fdbdd2bbe85dd948d10440e to your computer and use it in GitHub Desktop.
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);
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