Reputation: 40561
How does one write an if clause that would check to see if MutationObserver
is supported?
Upvotes: 6
Views: 4177
Reputation: 1
Try using in
operator
The in operator returns true if the specified property is in the specified object.
Syntax
prop in objectName
Parameters
prop
A string or symbol representing a property name or array index (non-symbols will be coerced to strings).
objectName
Name of an object.
if ("MutationObserver" in window) {
// do stuff
}
Upvotes: 12