---
title: "Comment by Simon Scarfe on \"My Favorite JavaScript Tips and Tricks\" | Hashnode"
description: "Great list - lots of lovely little tidbits, especially the isRequired helper function. Love that! You have to be slightly careful with the default or in 5, thou"
url: "https://hashnode.com/posts/my-favorite-javascript-tips-and-tricks/5f203086ba06442180226d0f/comment/5f255e52669da9610ee17812"
---

[Discussion](https://hashnode.com/posts/my-favorite-javascript-tips-and-tricks/5f203086ba06442180226d0f)

Comment [My Favorite JavaScript Tips and Tricks](https://hashnode.com/posts/my-favorite-javascript-tips-and-tricks/5f203086ba06442180226d0f)

[Simon Scarfe](https://hashnode.com/@si)

[Aug 1, 2020](https://hashnode.com/posts/my-favorite-javascript-tips-and-tricks/5f203086ba06442180226d0f/comment/5f255e52669da9610ee17812)

Great list - lots of lovely little tidbits, especially the `isRequired` helper function. Love that!

You have to be slightly careful with the default or in 5, though. If `age` is 0, it will overwrite it (making your new born person object a 35 year old 😉).

A safer, albeit slightly less-well-supported (IE doesn't know about it), way of attacking it is to use the nullish coalescing operator - `??` which returns truthy values such as 0.

More info available on MDN: [developer.mozilla.org/en-US/docs/Web/JavaScript/R…](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing_operator)

[Tapas Adhikary](https://hashnode.com/@atapas)

[Aug 1, 2020](https://hashnode.com/posts/my-favorite-javascript-tips-and-tricks/5f203086ba06442180226d0f/comment/5f255e52669da9610ee17812#reply-5f256440669da9610ee1784a)

Hey Simon,

Thank you very much for liking it and the encouraging words.

You got a great point about the defaults.. Thanks, really appreciate!
