JavaScript - Feature Detection

javascript

// JavaScript - Feature detection versus Feature Inference:

Feature inference is less reliable than feature detection.  Feature inference
is making assumption that a particular feature is available based on another
feature is available or not.  For example, Chrome implements the Text function. 
I also know Chrome doesn’t have applyElement like IE does.
if(typeof applyElement != 'undefined') {
    // now I know I'm not in IE, I'll just assume Text is available
    text = new Text('Oh, how quick that fox was!');
}
Someone looked at that code in Firefox which doesn’t implement applyElement or 
Text! They got an error.
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License