I am currently available for freelance/contract work. Book a meeting so we can talk about your project.

Destructuring the console object

Posted on

console is an object like any other. That means we can destructure from it like we do with other objects as well. The saved keystrokes might harm readability, so use this at your own discretion.

// Tired of writing “console.” all the time?
console.log("This sure is tiresome.")
console.warn("That’s a lotta keystrokes.")
 
// Destructure the functions from the console object.
const { log, warn } = console
log("Look ma, no console!")
warn("I’m going to let you do whatever.")
// Tired of writing “console.” all the time?
console.log("This sure is tiresome.")
console.warn("That’s a lotta keystrokes.")
 
// Destructure the functions from the console object.
const { log, warn } = console
log("Look ma, no console!")
warn("I’m going to let you do whatever.")
Debug
none
Grid overlay