Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
const log = new Proxy({}, {
get: (_, colour) => function() {
console.log(`%c ${[].slice.call(arguments).join(' ')}`, `color: ${colour}`)
}
})
// example
log.tomato('I am tomato')
log.chocolate('I am chocolate')
log.cornflowerblue('I am cornflowerblue')
log.darkcyan('I am darkcyan')
log.goldenrod('I am goldenrod')
@deepu105

This comment has been minimized.

Copy link

@deepu105 deepu105 commented Jan 8, 2018

log['#000000']('I am 000000'); you can do this as well

@robalb

This comment has been minimized.

Copy link

@robalb robalb commented May 21, 2019

Beautiful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment