javascript - Any specific use of double negation (!!) before new? -


i understand basic concept of double-negation- conversion bool - question specific use before new.

i looking way detect blob support , came across check on this page:

try { !!new blob(); } catch (e) { return false; }

i created example below demonstrate check failing.

window.onload=function()  {    var inputbox = document.getelementbyid('inputbox');    try {      !!new foo15514();      inputbox.value='supported';    } catch (e) {      inputbox.value='not supported';        }  }
<input id='inputbox' type=text/>

without getting whether approach blob detection or not, question have point of !! in case? far can tell superfluous, thought ask in case there missing.

!!new foo15514(), new foo15514(), var j = new foo15514() have same result.

update ball rolling - 1 thought had done force javascript engine evaluate rather skipping since has no effect, seems bad approach if case.

in case, indeed superfluous. using ! operator twice casts value boolean.

however, code read in bug report not complete (like typo). omitted important part of meant. if check commit made, picture looks different:

function test() {     try {         return !!new blob();     } catch (e) {         return false;     } } 

Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -