Not sure if this is the best place to ask, but doe...
# javascript
b
Not sure if this is the best place to ask, but does anyone know what this TS snippet does?
Copy code
const elm = vnode.elm = oldVnode.elm!
That double assignment confuses me
t
Copy code
vnode.elm = oldVnode.elm! // ! in TS = !! in Kotlin
const elm = vnode.elm
b
OMFG, another page of JS "magic"
Thanks, though
d
!
and
!!
are not quite the same.
!
doesn't check anything, it just tells TS to assume its not null
b
So
!
==
Any? as Any
and
!!
==
not null assertion like in kotlin
?
👌 1
d
No, there is no
!
equivalent in Kotlin
Any? as Any
is basically the same as
!!
But if you are translating this code, probably go with
!!
t
d
!
will never throw an exception, even if the operand is
null
.
!!
will
👌 1
t
Your truth
Copy code
// in Kotlin
vnode.elm = oldVnode.elm.unsafeCast<Elm>()
val elm = vnode.elm
n
Could that code snippet (in the original post) be a example of TS interacting with Elm ( https://elm-lang.org/ )?
b
No it's a snippet from snabbdom code
Elm stands for html dom element
😕 1