I am going through a book about HTML5 and there are two lines of code I cannot quite understand
var mp3Support,oggSupport;
var audio = document.createElement('audio');
if(audio.canPlayType) {
mp3Support = "" != audio.canPlayType('audio/mp3');
}
So, first you create an audio element and check if canPlayType method can be used? Then, the code inside the if statement is some kind of ternary operation?
The audio.canPlayType('audio/mp3') outputs 'probably' and mp3Support is set to '' but after that line mp3Support outputs true. Any tips would be much appreciated.