About the author: Lukas Gisder-Dubé co-founded and led a startup as CTO for 1.5 years, building the tech team and the architecture. After leaving the startup, he taught coding as Lead Instructor at Ironhack and is now building a startup agency & consultancy in Berlin. Check out dube.io to learn more.
Just recently, the team at Dubé launched Assetizr, which resizes, optimizes, and crops all kinds of images in a split second. Go ahead and check it out, it’s free!
LogRocket: Debug JavaScript errors more easily by understanding the context
Debugging code is always a tedious task. But the more you understand your errors, the easier it is to fix them.
LogRocket allows you to understand these errors in new and unique ways. Our frontend monitoring solution tracks user engagement with your JavaScript frontends to give you the ability to see exactly what the user did that led to an error.
LogRocket records console logs, page load times, stack traces, slow network requests/responses with headers + bodies, browser metadata, and custom logs. Understanding the impact of your JavaScript code will never be easier!
7 Replies to "12 tips for writing clean and scalable JavaScript"
Great tips, thanks! I disagree with No 3 though. I’ve found that passing arguments as destructured objects greatly improves readibility, when declaring the function AND when calling it, ie. displayUser({ firstName, lastName, age}).
I was going to comment about 3rd point but you had it already 🙂
Same ! Points 3 to be removed IMO. 🙂
Better yet, just use a Style Guide that’s much more in-depth and consistent than this blog post:
https://github.com/airbnb/javascript
Please delete the extra line break between the two function calls in #4.
#3 is not a good recommendation, and #4 is a perfect example of when you should pass an object to a method or function.
Always use spaces in conditionals:
“`
if(foo) // BAD
if (foo) // GOOD
“`
Why not use an arrow function in #9 when everything else in the post is ES6?
“`
cities.forEach((city) => {
…
})
“`
Why are there no async/await code samples in #10 that show their cleaner syntax in contrast to messy nested callbacks?
Lastly, nearly all JS Style Guides recommend the use of semicolons, particularly in cases where indentation can get odd with switch statements and method chaining.
A for effort, but this post should really be targeted at beginners.
I agree worh most of it, except for one thing.
Drop the console.
So web development world and each person contributing to development created this amazing tool to debug or code and you suggest dropping it, because of selling your product.
I find logrocket very valuable in production, but i would never lustened to this.
Great tips
Third point is not right in all scenarios, you can manage to declare the function argument as false in the declaration, but anyhow the sequence of passing the argument matters. It is not scalable in any of the ways.