Is there a way of storing a built-in javascript method in a variable to set different behaviour for when this method isn't available in certain browsers?
My specific case is for intersectionObserver which isn't available in Safari or older MS browsers. I have some animations triggered by this and would like to turn them off if intersectionObserver isn't available.
what I want to do essentially this:
var iO = intersectionObserver;
if ( !iO ) {
// set other defaults
}
I don't really want to load a polyfill or library for just one feature?
Many thanks
Emily
if("IntersectionObserver" in window)
?var iO = window.IntersectionObserver;
? – Roaster