Reputation: 16627
I need to check if a variable contains a CSSStyleRule. When using window.console.log(myvar)
it tells me CSSStyleRule { constructor=CSSStyleRule, type=1, more...}
, but when I use typeof myvar
it just tells me object
.
How can I check if it is really a CSSStyleRule?
Upvotes: 1
Views: 487
Reputation: 185963
This should do it:
myvar instanceof CSSStyleRule
This expression returns true/false.
Upvotes: 2
Reputation: 5932
You can check to see if the object has the selectorText
property:
if(myvar.selectorText) {
...
}
Upvotes: 1