Interoperability with JavaScript

After all the hard work we did to develop Kotlin code, what if we have a very crucial code well written, well tested, but written in JavaScript. Are we going to convert it into Kotlin? No. The way Kotlin code can interoperate with Java, Kotlin for JavaScript is interoperable with JavaScript. This means JavaScript can call Kotlin code and Kotlin can call JavaScript code.

We have covered this as well. Kotlin does not have a Date class that can accept a date in UTC format, but JavaScript has. We will format our dates in JavaScript and Kotlin will call those functions.

We wrote three functions in our index.html file just inside a <script> tag and preceding the Kotlin <script> tags. The sequence does matter here! ...

Get Kotlin Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.