October 2019
Intermediate to advanced
434 pages
11h 54m
English
A question that arises foremost is what we can do with our JavaScript once it's been transpiled from Kotlin. The simplest usage is to load the resulting script into an HTML page and execute whatever code we've defined in our main function.
For example, we can define a Kotlin main() function that prints to the console, as in the following example:
fun main(args: Array<String>) { val message = "Hello Kotlin JavaScript" println(message)}// outputs "Hello Kotlin JavaScript"
We can load the transpiled JavaScript equivalent of this code using a <script> tag with an HTML document to print out "Hello Kotlin JavaScript" to the console in our browser. We will see exactly how to do this in the very next section.
Beyond ...
Read now
Unlock full access