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
/>;
Top comments (2)
So its a good way to do something only when what you are evaluating is true. Thank you.
Boolean(dataToDelete)