It makes sure that it returns a boolean value as opposed to something truthy/falsy which could lead to oddness if you try and directly compare it with a boolean value.
According to the spec, media.canPlayType returns either "", "maybe" or "probably". An empty string "" is falsy in Javascript and a non-empty string is truthy, but if you try and compare them directly with booleans then you can get some odd behaviour:
if ("yes"){ // true }
if ("yes" == true){ // false }
if ("yes" === true){ // false }
if (""){ // false }
if ("" == false){ // true }
if ("" === false){ // false }
I personally prefer to make sure that any function which you're expecting the return value to be used as a boolean actually returns a boolean value. I know there are many people out there with a dislike of !! though.
It's to magnify the emotion expressed. In the olden days, before emoticons, people used a larger vocabulary to express themselves, but often times that failed to express the magnitude of their feelings. They used !! for that purpose. Of course, today we see the abuse of the !! quite rampant. I LOVE YOUR HTML5!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! is an example of this. Note that this is a post-fix operator.
Hah! I am guilty of over using exclamation marks in posts/texts. I eventually found myself re-reading messages and stripping them out! Unfortunately, nowadays, it's emoticons I overuse. :)
Thanks, and a note: under FFox3.5/Linux, I noticed a small delay before the title fonts (Agnes Nutter style ;-) loaded over something simpler. More interestingly, I cannot select the words "Appendix A" to copy elsewhere. I checked the source, and see they're in style ( h1:before{content:"Appendix A:"} ).
Curiously, under Konqueror 4.3 I can highlight those words, together with the rest of the title, but pasting (either X or ^c^v) also misses them ...
Ah, the oddities of CSS. The first issue is because I'm using custom fonts via @font-face. Firefox has made some... design decisions... that cause the effect you're seeing. I've actually just recently discovered a way to reduce the number of dynamic fonts I'm loading, but the underlying issue is still that Firefox wants to paint the page before the dynamic fonts are finished loading.
The second issue is CSS generated content. I honestly don't remember why I chose to put chapter numbers and appendix letters in CSS and the rest of the title in content. Purity? Really? That doesn't sound like me. ;-) It would probably be simpler to move it all into the h1.
Some browsers don't support OTF fonts (like Android?) I can't seem to find a way to detect that short of getting into subtleties of WebKit revisions, but even that doesn't seem to denote support.
I'm constantly confused by 'HTML5', because many of these examples look more like Javascript than a markup language. I've used HTML5 a bit here and there, but just as the next version of XHTML, using things like the <article> tag.
HTML5 is a set of enhancements to HTML and to the JavaScript DOM API. This page is actually a great summary of HTML5 features that developers are likely to care about. For instance:
- The <audio> and <video> elements
- The <canvas> element
- Form validation (without JavaScript!)
- New <input>s for data like dates, times, numbers, ranges, and colors, for which the UA can provide OS-native controls
- An API for cross-domain communication between windows
- An API for providing and accepting drag and drop within, between, into, and out of browser windows
- Web Workers for computation in the background
- Web Sockets for efficient communication with your server
- A persistent local database
...and much more!
This page focuses on detecting support for many HTML5 features in JavaScript, so that a developer could, say, swap in their own datepicker if the browser doesn't offer one.
The examples are all JavaScript code to detect support for new html5 tags/features. If the client doesn't support one, for example <video>, you can fail gracefully and maybe offer an alternative piece of content eg Flash.
My longer chapter on detecting HTML5 features ( http://diveintohtml5.org/detect.html ) explains the detection patterns, and shows how to detect things with or without Modernizr. I've been working with the Modernizr developers to expand their detections, and at the same time some of the code in this guide is taken directly from Modernizr.
This crowd has zero sense of humor. This post was meant to be seen in light of all the Flash gnashing and public war with adobe... Sigh. Thanks for the neg karma.
http://mylittlehacks.appspot.com/html5