DEV Community

Discussion on: with(ConfigObject) { "Language $KOTLIN".isSparkingJoy() }

Collapse
 
kip13 profile image
kip

In JS you have the with statement too:

const myObj = {test: 123}
const test = "is a test !"

with (myObj) { console.log(test) }
console.log(test)

Collapse
 
jmfayard profile image
Jean-Michel πŸ•΅πŸ»β€β™‚οΈ Fayard • Edited

I had forgotten, thank you! Not doing so much JavaScript those days.
A difference with Kotlin is that we have strong static typing - with type inference.
So much of the stated problems for the with statement do not apply.