Become a member
to unlock all features

Create an egghead account to access 5000+ tutorials and resources from expert developers.

Create account

    Use the Nullish Coalescing Operator to Set Object Defaults


    The nulliish coalescing operator (??) allows us to be more explicit when setting object defaults. It allows us to ensure that only values that are "nullish" (either null or undefined) cause the default value to be taken, rather than anything that evaluates to false.

    It's a safer way to operate.

    Please note: This feature is still making its way through the TC39 proposal process. To use it in your project today, you can enable it using Babel's Nullish Coalescing plugin.