What would be your fastest, shortest (best) way to detect browser which is IE and version less than 9 in JavaScript, without using jQuery or any add-on libraries?
if (+(/MSIE\s(\d+)/.exec(navigator.userAgent)||0)[1] < 9) {
// IE8 or less
}
/MSIE\s(\d+)/.exec(navigator.userAgent)null so in that case ||0 will switch that null to 0[1] will get major version of IE or undefined if it was not an IE browser+ will convert it into a number, undefined will be converted to NaNNaN with a number will always return false