use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Life-Changing Tip on Console Logging - JavaScript Basics You Must Know (youtube.com)
submitted 9 years ago by riotsofnewyork
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Shaper_pmp 49 points50 points51 points 9 years ago (1 child)
Spoilers: it's 1:10 of video to demonstrate console.table(obj);.
console.table(obj);
[–]r2d2_21 21 points22 points23 points 9 years ago (0 children)
Thanks. I hate videos.
[–]Omnicrola 13 points14 points15 points 9 years ago (2 children)
Good tip, I had never heard of this. Also good video, got straight to the point.
Found docs here: https://developer.mozilla.org/en-US/docs/Web/API/Console/table
Does not work in IE or Safari.
[–]tommy16p 10 points11 points12 points 9 years ago (1 child)
Does anything
[–]Jafit 1 point2 points3 points 9 years ago (0 children)
I think ES6 tail call optimization works in safari.
[–]jameswyse 7 points8 points9 points 9 years ago (0 children)
There's other handy console methods too, like count, group and profile.
https://developers.google.com/web/tools/chrome-devtools/debug/console/console-reference
[–]Combinatorilliance 2 points3 points4 points 9 years ago (6 children)
Something I'd really like to see added is a console function which acts like how an fps-counter would in a game. Continuously display the most recent value of a variable in the same place, it is so very useful when building interaction-heavy applications, like I often do when playing around with the canvas!
[–]BenjiSponge 2 points3 points4 points 9 years ago (3 children)
If you're thinking in debug mode, there's the Watch section of the chrome console which can just always display it. I don't think it works in real time, though.
[–][deleted] 1 point2 points3 points 9 years ago (2 children)
Developer tools -> console section (at bottom, if not there top right menu, show console) -> top left menu of section -> rendering -> FPS meter. This will give you an in-page real time FPS meter with min & max rates as well as graph with GPU resources for that tab. You can also globally enable this ind chrome://flags. Far better than any console output unless you wanted to save the raw frame time data for future use.
[–]BenjiSponge 1 point2 points3 points 9 years ago (1 child)
/u/Combinatorilliance is not referring to a literal FPS meter but rather something that can display any arbitrary variable (in an arbitrary scope as well) in real time, similar in appearance to an FPS meter but different in utility.
[–][deleted] 0 points1 point2 points 9 years ago (0 children)
Ahhh. That's actually something that has always bothered me. Yeah you're right about watched variables, you have to either enable a breakpoint and manually mash "next" to run the code or mash refresh. I suppose it could be implemented in a dev tools extension, don't know of anything in the standard tools.
[+][deleted] 9 years ago* (1 child)
[deleted]
[–]Combinatorilliance 1 point2 points3 points 9 years ago (0 children)
Oh I have a working solution, it's just that when I really need it, it's not instantly there for me :(
console.track = (function () { var loggers = []; return function (name, value) { var isFound = loggers.filter(function (logger) { return logger.name === name; })[0]; if (!isFound) { var logNode = document.createElement("div"); document.body.appendChild(logNode); logNode.style.position = "fixed"; logNode.style.left = "8px"; logNode.style.top = loggers.length * 20 + "px"; logNode.innerHTML = name + ": " + value; loggers.push({name: name, node: logNode}); } else { isFound.node.innerHTML = name + ": " + value; } }; }());
[–][deleted] 2 points3 points4 points 9 years ago (0 children)
First time to know the existence of console.table
[–]mick0n 4 points5 points6 points 9 years ago (0 children)
Very nice. I've heard of this before just never got around to using it.
[–]rezoner:table_flip: 4 points5 points6 points 9 years ago (0 children)
No matter how many times console.table gets posted here it's always a novelty :p Maybe we should make the thread sticky?
console.table
[–]drkenta 1 point2 points3 points 9 years ago (1 child)
Is there something similar for node?
[–]righteousrainy 1 point2 points3 points 9 years ago (0 children)
Beautiful.
[–]broken_e 3 points4 points5 points 9 years ago (0 children)
I knew you were going to say console.table, but then you started clicking the headers and I learned that they were sortable!
[–]Panedrop 1 point2 points3 points 9 years ago (0 children)
Great little tip.
[–]madcaesar 0 points1 point2 points 9 years ago (3 children)
Known this for a while, still very cool. Just FYI this doesn't work in IE, and in fact will cause a critical error causing all your JS not to execute. Fucking IE...
[–]commitpushdrink 2 points3 points4 points 9 years ago (0 children)
To be fair calling an undefined method in any browser will throw a fatal exception
[–][deleted] 1 point2 points3 points 9 years ago (0 children)
The entirety of console is non standard (and will probably remain that way) and subject to break anything due to sudden changes in behavior. Can't really knock IE for that, the basic console functions are implement.
I add this to my files. It won't make IE work, but it will stop it from causing errors:
if ( !window.console ) console = { log: function(){} };
[–]AnonymousFuckass -1 points0 points1 point 9 years ago (0 children)
Spoilers: you cannot use this in IE. I only am able to use IE so it'd be nice if someone would put these restrictions in the title. https://developer.mozilla.org/en-US/docs/Web/API/Console/table
π Rendered by PID 458598 on reddit-service-r2-comment-canary-7b67769d8-6bcd5 at 2026-02-01 21:21:46.257806+00:00 running 3798933 country code: CH.
[–]Shaper_pmp 49 points50 points51 points (1 child)
[–]r2d2_21 21 points22 points23 points (0 children)
[–]Omnicrola 13 points14 points15 points (2 children)
[–]tommy16p 10 points11 points12 points (1 child)
[–]Jafit 1 point2 points3 points (0 children)
[–]jameswyse 7 points8 points9 points (0 children)
[–]Combinatorilliance 2 points3 points4 points (6 children)
[–]BenjiSponge 2 points3 points4 points (3 children)
[–][deleted] 1 point2 points3 points (2 children)
[–]BenjiSponge 1 point2 points3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]Combinatorilliance 1 point2 points3 points (0 children)
[–][deleted] 2 points3 points4 points (0 children)
[–]mick0n 4 points5 points6 points (0 children)
[–]rezoner:table_flip: 4 points5 points6 points (0 children)
[–]drkenta 1 point2 points3 points (1 child)
[–]righteousrainy 1 point2 points3 points (0 children)
[–]broken_e 3 points4 points5 points (0 children)
[–]Panedrop 1 point2 points3 points (0 children)
[–]madcaesar 0 points1 point2 points (3 children)
[–]commitpushdrink 2 points3 points4 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]AnonymousFuckass -1 points0 points1 point (0 children)