2019-05-07
1970
#vanilla javascript
Lukas Gisder-Dubé
1731
May 7, 2019 ⋅ 7 min read

12 tips for writing clean and scalable JavaScript

Lukas Gisder-Dubé Passionate about technology, design, startups and personal development. Bringing ideas to life at dube.io.

Recent posts:

Radix Ui Adoption Guide Overview Examples And Alternatives

Radix UI adoption guide: Overview, examples, and alternatives

Radix UI is quickly rising in popularity and has become an excellent go-to solution for building modern design systems and websites.

Nefe Emadamerho-Atori
Apr 25, 2024 ⋅ 11 min read
Understanding The Css Revert Layer Keyword, Part Of Css Cascade Layers

Understanding the CSS revert-layer keyword

In this article, we’ll explore CSS cascade layers — and, specifically, the revert-layer keyword — to help you refine your styling strategy.

Chimezie Innocent
Apr 24, 2024 ⋅ 6 min read
Exploring Nushell, A Rust Powered, Cross Platform Shell

Exploring Nushell, a Rust-powered, cross-platform shell

Nushell is a modern, performant, extensible shell built with Rust. Explore its pros, cons, and how to install and get started with it.

Oduah Chigozie
Apr 23, 2024 ⋅ 6 min read
Exploring Zed, A Newly Open Source Code Editor Written In Rust

Exploring Zed, an open source code editor written in Rust

The Zed code editor sets itself apart with its lightning-fast performance and cutting-edge collaborative features.

Nefe Emadamerho-Atori
Apr 22, 2024 ⋅ 7 min read
View all posts

7 Replies to "12 tips for writing clean and scalable JavaScript"

  1. 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}).

  2. 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.

  3. 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.

  4. 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.

Leave a Reply