basickarl
basickarl

Reputation: 40561

Check if browser supports MutationObserver

How does one write an if clause that would check to see if MutationObserver is supported?

Upvotes: 6

Views: 4177

Answers (1)

guest271314
guest271314

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

Related Questions