This is an interactive tutorial for futures. The code samples are intended to look and behave like Java but it's actually JavaScript.
->
is automatically converted to =>
so you can write lambdas like in Java.
Unlike in Java, the exceptions here are simply strings instead of being full Exception objects with stack traces.
Additionally, there are no generics here, so just ignore that aspect for now. For these exercises, all the futures will
effectively be CompletableFuture<String>
.
The CompletableFuture API you can use here is a partial re-implementation in JavaScript. The functions you can use are listed below:
Since Java 8:
Since Java 9:
Since Java 12: