Snippets

Andrew Alba JavaScript Console Cheats

Created by Andrew Alba
// The basics

console.log("console log") // standard output
console.info("console info") // standard output
console.debug("console debug") // blue text output
console.warn("console warn") // warning icon with orange text output
console.error("console error") // error icon with red text output


// JavaScript with "style" :)

console.log("%cAlba Web Studio", "color: CornflowerBlue; font-size: 2rem;")
console.log("%cAlba %cWeb Studio", "color: white; font-size: 1.5rem;", "color: CornflowerBlue;")


// Tables

let tableData = [["Andrew"],["Pauline"],["Dayton"],["Gage"],["Kobe"]]
console.table(tableData)

// Groups

console.group()
    console.log("Root Message")
    console.group("Secondary Message")
        console.log("Item One")
        console.log("Item Two")
    console.groupEnd()
console.groupEnd()


// navigate through object properties

let info = {
    "businessName": "Alba Web Studio",
    "slogan": "imaginative designs and solutions",
    "website": "https://albaweb.studio"
}
console.dir(info)

console.dirxml(document.body)


// Assert | will only print false arguments

let name = "Andrew"
let msg = "! Hotdog"
console.assert(typeof msg === "number", {name: name, msg: msg})


// You can "count" on it

for (let i = 0; i < 10; i++) { console.count("Aah-aah-aah") }


// Check speed of execution

console.time("Time")
let j = 0
for (let i = 0; i< 10; i++) { j += i }
console.log("total", j)
console.timeEnd("Time")

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.