Interoperability with JavaScript

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

Each function is giving a call to a JavaScript function using a js("...") function.

You might have noticed this function's call in our code snippet. Why did we use this? In Node.js, snapShot.val() gives you the actual data. But val is the keyword in Kotlin, so we do not have a way to call the val() ...

Get Hands-On Serverless Applications with Kotlin 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.