js

Platform and version requirements: JS (1.1)
fun js(code: String): dynamic

Puts the given piece of a JavaScript code right into the calling function. The compiler replaces call to js(...) code with the string constant provided as a parameter.

Example:

fun logToConsole(message: String): Unit {
    js("console.log(message)")
}

Parameters

code - the piece of JavaScript code to put to the generated code. Must be a compile-time constant, otherwise compiler produces error message. You can safely refer to local variables of calling function (but not to local variables of outer functions), including parameters. You can't refer to functions, properties and classes by their short names.

Platform and version requirements: JS (1.1)
val <T : Any> KClass<T>.js: JsClass<T>

Obtains a constructor reference for the given KClass.

© 2010–2021 JetBrains s.r.o. and Kotlin Programming Language contributors
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.js/js.html