forEach polyfill for IE11
if (window.NodeList && !NodeList.prototype.forEach) {
NodeList.prototype.forEach = Array.prototype.forEach;
}
Swap out 'no-js' class on HTML element
Add this into the <head> of your page to replace .no-js with .js when javascript is available (similar approach to Modernizr)
<script>
document.documentElement.className=document.documentElement.className.replace(/\bno-js\b/,'') + ' js'; // Set approprate js class on html element
</script>
Check if a javascript variable is defined
if (typeof variable === 'undefined') {
// variable is undefined
}