如何编写一个 if 子句来检查是否支持 MutationObserver
?
最佳答案
尝试使用 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
}
关于javascript - 检查浏览器是否支持 MutationObserver,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34829327/