Did you know that it's possible to set default value in Javascript object destructuring?

Table of contents

    Let see how it works in action:

    > { firstName = "John" } = {}
    {}
    > firstName
    'John'

    One thing to keep in mind is that it only works with undefined values. It won't work with null, false and 0 as these are normal values.

    > { firstName = "John" } = { firstName: null }
    { firstName: null }
    > { firstName = "John" } = { firstName: 0 }
    { firstName: 0 }
    > {firstName = "John"} = { firstName: false }
    { firstName: false }
    Szymon Soppa Web Developer
    Szymon Soppa Curiosum Founder & CEO

    Read more
    on #curiosum blog

    Introducing Kanta - the ultimate solution to translations in Elixir web apps

    Introducing Kanta - the ultimate solution to translations in Elixir & Phoenix web apps

    Handling translations in web applications can be a challenging and time-consuming task. The process entails managing various files, tracking modifications, and ensuring that translations remain current as the project progresses. These complexities can slow down development and introduce errors. That’s why we decided to create an open source solution: Kanta. In this blog post, we’ll explore the problem of managing translations in web apps, and how Kanta simplifies the process. We’ll also compare it with other translation management tools and delve into its powerful plugins.