Pls help me understand this construction

var canPlayAudioFiles = !!(document.createElement('audio').canPlayType);

this is from an HTML5 book, to test whether the browser supports <audio> tag…

I don’t understand the ‘!!’ before the parens… I have never seen this before… is this jQuery or plain Javascript?
(asking because this line occurs inside a typical jQuery

$(function() { 

thingie… )

could this be done with a classic boolean function/method???

Hi,

The double bang(!!) forces a boolean value out of any statement. This is plain 'ol javascript.

It will change ‘falsy’ values like nil / undefined into false.