Deep
Deep's Blog

Deep's Blog

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

Deep's photo
Deep
·Feb 7, 2021·

1 min read

Subscribe to my newsletter and never miss my upcoming articles

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
/>;
 
Share this