<p dir="auto"><strong>Many webdevelopers still debug with <code>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...
<h2>Got an array of objects?
<p dir="auto">Check out <code>console.table.<br />
Here you can see what it looks like with <code>console.log:<br />
<img src="https://images.hive.blog/768x0/https://stuff.flovolution.com/blog/console.log-1-output.PNG" alt="console.log(authors)" srcset="https://images.hive.blog/768x0/https://stuff.flovolution.com/blog/console.log-1-output.PNG 1x, https://images.hive.blog/1536x0/https://stuff.flovolution.com/blog/console.log-1-output.PNG 2x" /><br />
<br /><br />
And here with <code>console.table:<br />
<img src="https://images.hive.blog/768x0/https://stuff.flovolution.com/blog/console.table-output.PNG" alt="console.table(authors)" srcset="https://images.hive.blog/768x0/https://stuff.flovolution.com/blog/console.table-output.PNG 1x, https://images.hive.blog/1536x0/https://stuff.flovolution.com/blog/console.table-output.PNG 2x" /><br />
<br /><br />
It's a hell of a difference, isn't it?
<h2>Got an DOM-object?
<p dir="auto"><code>console.dir is your friend.<br />
Here with <code>console.log:<br />
<img src="https://images.hive.blog/768x0/https://stuff.flovolution.com/blog/console.log-2-output.PNG" alt="console.log(authors)" srcset="https://images.hive.blog/768x0/https://stuff.flovolution.com/blog/console.log-2-output.PNG 1x, https://images.hive.blog/1536x0/https://stuff.flovolution.com/blog/console.log-2-output.PNG 2x" /><br />
<br /><br />
And here with <code>console.dir<br />
<img src="https://images.hive.blog/768x0/https://stuff.flovolution.com/blog/console.dir-output.PNG" alt="console.log(authors)" srcset="https://images.hive.blog/768x0/https://stuff.flovolution.com/blog/console.dir-output.PNG 1x, https://images.hive.blog/1536x0/https://stuff.flovolution.com/blog/console.dir-output.PNG 2x" /><br />
<br />
<h2>Measure times?
<p dir="auto">Are you tired of subtracting timestamps? Just use <code>console.time & <code>console.timeEnd.<br />
<img src="https://images.hive.blog/768x0/https://stuff.flovolution.com/blog/console.time-output.PNG" alt="console.log(authors)" srcset="https://images.hive.blog/768x0/https://stuff.flovolution.com/blog/console.time-output.PNG 1x, https://images.hive.blog/1536x0/https://stuff.flovolution.com/blog/console.time-output.PNG 2x" />
<h2>Upcoming?
<p dir="auto">What do you want to see next?
<ul>
<li>How to Pi-Hole
<li>PWA #3
<li>something different
<p dir="auto">Let me know in the comments below.
<hr />
<p dir="auto">With that in mind, happy coding.
<pre><code>(() => {
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));
})();
🔧console.tricks you might not know about
7 years ago in #programming by drookyn (48)
$18.70
- Past Payouts $18.70
- - Author $14.12
- - Curators $4.59
24 votes
- sndbox: $17.64
- voronoi: $0.88
- playitforward: $0.06
- erb: $0.04
- rilc0n: $0.03
- aaronleang: $0.02
- neutronenkind: $0.00
- sidem: $0.00
- burstfire: $0.00
- patlongus: $0.00
- drookyn: $0.00
- world-travel-pro: $0.00
- espoem: $0.00
- flashfiction: $0.00
- elizacheng: $0.00
- alfarisi: $0.00
- animagic: $0.00
- slefesteem: $0.00
- gcamkerten: $0.00
- creativista: $0.00
- and 4 more
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 :)
didn't know about these really cool!
Looking forward to the pi-hole tutorial :)Nice post @drookyn,
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 👍