Deep PatelNavigate back to the homepage

What is the !! (not not) operator in JavaScript?

Deep Patel
August 1st, 2021 · 1 min read

Converts Object to boolean. If it it falsey (e.g. 0, null, undefined, etc.), it will be false, otherwise, true.

1!oObject // inverted boolean
2!!oObject // non inverted boolean so true boolean

Representation

So !! is not an operator, it’s just the ! operator twice.

Example :

1<CustomModal
2 disabled={isDisable}
3 title="Delete"
4 children="Are you sure you want to delete ?"
5 onCancel={() => setDataToDelete(null)}
6 onConfirm={() => {}}
7 show={!!dataToDelete} //show only accepts boolean
8/>;

More articles from Deep Patel

Handling multiple API calls with Promise.allSettled()

Handling multiple API calls with Promise.allSettled().

January 17th, 2021 · 1 min read

Create/ Publish your first NPM package

Create/ Publish your first NPM package.

June 14th, 2020 · 1 min read
© 2020–2022 Deep Patel
Link to $https://twitter.com/pateldeep_ethLink to $https://github.com/deep1144Link to $https://www.instagram.com/deep__1144/Link to $https://www.linkedin.com/in/patel-deep-dev/Link to $https://dribbble.com/Deep1144