Feature Detection and Feature Inference

Feature Detection

Check to see if the browser supports the given code. is best to handle feature detection.

if(window.localStorage) { /*...*/ } else {}

💡 This is mostly used to check the API on either Old browsers (like IE).

Feature Inference

Feature inference checks for a feature x and assumes feature y is also available

if(window.Intl) {   window.Intl.Locale(); // Locale is not supported in IE}

🚨 Don't prefer to use inference.