how to create JavaScript anonymous object in kotlin? i want to create exactly this object to be passed to nodejs app
var header = {“content-type”:”text/plain” ,
Here's a helper function to initialize an object with a lambda syntax
inline fun jsObject(init: dynamic.() -> Unit): dynamic { val o = js("{}") init(o) return o }
Usage:
jsObject { foo = "bar" baz = 1 }
Emited javascript code
var o = {}; o.foo = 'bar'; o.baz = 1;