Sitemap

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

Feb 7, 2021

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

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

Representation

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

Example :

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

--

--

No responses yet