Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Kotlin Blueprints

You're reading from   Kotlin Blueprints A practical guide to building industry-grade web, mobile, and desktop applications in Kotlin using frameworks such as Spring Boot and Node.js

Arrow left icon
Product type Paperback
Published in Dec 2017
Publisher Packt
ISBN-13 9781788390804
Length 260 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (3):
Arrow left icon
Akshay Chordiya Akshay Chordiya
Author Profile Icon Akshay Chordiya
Akshay Chordiya
Ashish Belagali Ashish Belagali
Author Profile Icon Ashish Belagali
Ashish Belagali
Hardik Trivedi Hardik Trivedi
Author Profile Icon Hardik Trivedi
Hardik Trivedi
Arrow right icon
View More author details
Toc

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! Consider the following code snippet:

    <script>
window.getShortDate = function(longDate) {
var options={month...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image