do you know a good way to check if a variable is the window object in javascript? I tried with:
var variable=window;
Object.prototype.toString.call(variable);
In Firefox it returns "[object Window]"
but in IE "[object Object]"
so that's not the right way. Do you know an accurate way to check it?
Found this in AngularJS source code. A one liner and bang on target.
return variable && variable.document && variable.location && variable.alert && variable.setInterval;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With