javascript double exclamation mark code example

Example 1: javascript on double click

document.getElementById("myBtn").addEventListener("dblclick", function() {
  alert("Hello World!");
});

Example 2: double question mark javascript

//Similar to || but only returns the right-hand operand if the left-hand is null or undefined
0 ?? "other" // 0
false ?? "other" // false
null ?? "other" // "other"
undefined ?? "other" // "other"

Example 3: javascript double exclamation mark

const isIE8 = !! navigator.userAgent.match(/MSIE 8.0/);  
console.log(isIE8); // returns true or false

Example 4: javascript double exclamation mark

console.log(!!navigator.userAgent.match(/MSIE 8.0/));  
// returns either true or false

Example 5: javascript double exclamation mark

console.log(navigator.userAgent.match(/MSIE 8.0/));  
// returns either an Array or null

Example 6: javascript double exclamation mark

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