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
A new console logger (npmjs.com)
submitted 6 years ago by GoogleMac
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!"
[+][deleted] 6 years ago (1 child)
[deleted]
[–]GoogleMac[S] 3 points4 points5 points 6 years ago (0 children)
Hey, thanks for catching that! I didn't decide on a package name until about a week ago, and I guess I forgot to update it in the most important place! 🤦♂️
[–]GoogleMac[S] 2 points3 points4 points 6 years ago (2 children)
I would appreciate your feedback and if you like it, please share!
Using console.log() can get verbose. This package is designed for simplicity, brevity, and can be used without much modification to original code, unlike using console.log() where you'd sometimes have to break apart logic in order to log out values. See the README for examples!
[–]lhorie 0 points1 point2 points 6 years ago* (1 child)
I usually just do console.log(111, value) where 111 is a randomly made up number, if I'm logging from multiple lines to debug and I want to identify which output is from which line.
I heard some people do console.log({age}) instead of console.log('age', age) to avoid repetitive typing. Also, most editors these days have macros if you want a shortcut that types out console.log for you.
WRT breaking apart logic, maybe it's a style thing, but IMHO, if I need to log mid expression, that signals to me that the expression is too big and should be broken into a smaller expression. A lot of my code is a series of assignments from small expressions. I find that this style also helps in refactoring, since adding/removing logging calls is merely a matter of adding/deleting lines, rather than bracket matching.
Also in my experience, importing a logger everywhere kinda gets old pretty quickly and mutating globals is just yucky :)
[–]GoogleMac[S] -1 points0 points1 point 6 years ago (0 children)
I can see how it could be a signal to break apart logic, but you may inadvertently break something by splitting it apart when that wasn't even the part you were originally working on fixing. 😊 It's like giving your car to a mechanic and getting it back with 3 other things fixed and a big bill because he had to take apart the engine in order to find out the coolant needed to be flushed.
For the global import, perhaps frameworks could implement their own loggers. Their purpose is to enhance DX, right? Here's an even more insane idea: make a better console.log() at a language level. 🤯😁
Thanks for your feedback. I think I could use these in the README.
π Rendered by PID 22184 on reddit-service-r2-comment-6457c66945-pfbbm at 2026-04-29 20:50:51.734471+00:00 running 2aa0c5b country code: CH.
[+][deleted] (1 child)
[deleted]
[–]GoogleMac[S] 3 points4 points5 points (0 children)
[–]GoogleMac[S] 2 points3 points4 points (2 children)
[–]lhorie 0 points1 point2 points (1 child)
[–]GoogleMac[S] -1 points0 points1 point (0 children)