如何写一个if子句来检查是否支持MutationObserver
?
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
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.