🔧console.tricks you might not know about

in #programming6 years ago

banner

Many webdevelopers still debug with console.log. But there are more cool features you may not know about. To be clear: I would not recommend debugging with those, but sometimes...

Got an array of objects?

Check out console.table.
Here you can see what it looks like with console.log:
console.log(authors)


And here with console.table:
console.table(authors)


It's a hell of a difference, isn't it?

Got an DOM-object?

console.dir is your friend.
Here with console.log:
console.log(authors)


And here with console.dir
console.log(authors)

Measure times?

Are you tired of subtracting timestamps? Just use console.time & console.timeEnd.
console.log(authors)

Upcoming?

What do you want to see next?

  • How to Pi-Hole
  • PWA #3
  • something different

Let me know in the comments below.


With that in mind, happy coding.

(() => {
  const colors = [
    '001f3f', '0074d9', '7fdbff', '39cccc',
    '3d9970', '2ecc40', '01ff70', 'ffdc00',
    'ff851b', 'ff4136', '85144b', 'f012be',
  ];
  const contents = ['%cI', '%c❤', '%cweb', '%cdev'];
  const options = Array.from(
    new Array(contents.length),
    () => `
      color:#${colors[Math.floor(Math.random() * colors.length)]};
      font-size:64px;
    `
  );
  console.log.apply(console, [contents.join('')].concat(options));
})();
Sort:  

Hello, your post was nominated for an upvote by a fellow within the Sndbox incubator. Thanks for sharing your console tricks @drookyn. Steem on :D

Very nice, thanks :)

Nice post @drookyn,
didn't know about these really cool!
Looking forward to the pi-hole tutorial :)

Vielleicht sollte ich meinen Javascript Kurs bei Udemy endlich mal weiter machen ... :D

Auf Udemy lernt man etwas? :D
Schreib mir einfach mal auf, wie du die ein gelungenes JavaScript Tutorial vorstellst & ich mach ne Serie draus. Auf meinem Plan steht eh schon ES6 :)

Ja doch, schon. Kommt halt auf den Kurs an würde ich sagen. Nur mein Verständnis für JS is recht beschränkt. Ich als Designer habs einfach mehr mit Bildern und nicht so mit "logik" wenn du verstehst was ich meine ;-)
Daher fällt mir der Kurs für CSS3 & HTML5 irgendwie leichter. Damit kann ich auch so an sich viel mehr anfangen in der Praxis.

Mach lieber Frontend Kurse, da hab ich mehr von ;-)

Alles klar, mach ich 👍

Coin Marketplace

STEEM 0.28
TRX 0.13
JST 0.032
BTC 60793.50
ETH 2910.51
USDT 1.00
SBD 3.59