Just declare extension function for that: ``` fun ...
# javascript
g
Just declare extension function for that:
Copy code
fun Any.hasOwnProperty(property: String): Boolean {
    return asDynamic().hasOwnProperty(property) == true
}
f
hasOwnProperty
always returns boolean, no need to
== true
g
It's to get rid of warning about autocast from dynamic to Boolean
a
You could also use
.unsafeCast<Boolean>()
. This should yield no warnings and no extra code.
b
@anton.bannykh how is that better than
== true
? Seems like more code to me…
g
Probably Anton means that there is less code in compiled JS file (no additional bool check) But it fits nicely with code style for nullable booleans. Not the same of course, just looks natural for me after work with nullable booleans
b
That’s fair 🙂 Thank y’all for the help!
a
Yes, less compiled code.