<@UFC7B9QPM> something like `js("typeof window !==...
# javascript
g
@thana something like
js("typeof window !== undefined") as Boolean
t
yeah that's what i tried to avoid 😄
r
why not just:
Copy code
if (window != undefined) {
}
s
@thana Alternatively you can do it with
jsTypeOf(window) == "undefined"
. @Robert Jaros Accessing undefined variable will result in a
ReferenceError
.
💯 2
r
So why this is working fine?:
Copy code
if (window.asDynamic().blah == undefined) {
}
s
JavaScript 🤷‍♂️. It's not an error to access undefined property.
r
window != undefined
is translated as
!Kotlin.equals(window, undefined)
and from I can see in the sources this function should work fine for undefined
window
s
Try typing
window;
statement in node.js console.
r
true, I was wrong
t
@Svyatoslav Kuzmich [JB]
jsTypeOf
lloks great, thank you 🙂