More Related Content Similar to An Introduction to Scala JS (20) More from Knoldus Inc. (20) An Introduction to Scala JS2. Lack of etiquette and manners is a huge turn off.
KnolX Etiquettes
Punctuality
Respect Knolx session timings, you
are requested not to join sessions
after a 5 minutes threshold post
the session start time.
Feedback
Make sure to submit a constructive
feedback for all sessions as it is
very helpful for the presenter.
Mute
Be on mute until you have
questions or concerns.
Avoid Disturbance
Avoid unwanted chit chat during
the session.
10. const personMap = new Map([
[10, new Person("Roger", "Moore")],
[20, new Person("James", "Bond")]]);
const names = [];
for (const [key, person] of personMap)
{
if (key > 15)
{
names.push(`${key} = ${person.firstName}`);
}
}
val personMap = Map(
10 -> new Person("Roger", "Moore"),
20 -> new Person("James", "Bond"))
val names = for
{
(key, person) <- personMap
if key > 15
} yield s"$key = ${person.firstName}"
11. const xhr = new XMLHttpRequest();
xhr.open("GET", "http://localhost:8080”);
xhr.onload = (e) =>
{
if (xhr.status === 200)
{
const r = JSON.parse(xhr.responseText);
$("#id").html(parse(r));
}
};
xhr.send();
val xhr = new XMLHttpRequest()
xhr.open("GET", "http://localhost:8080”)
xhr.onload =
{
(e: Event) =>
if (xhr.status == 200)
{
val r = JSON.parse(xhr.responseText)
$("#id").html(parse(r))
}
}
xhr.send()
13. class Person
{
public firstName: String;
public lastName: String;
constructor(firstName: string,
lastName: string)
{
this.firstName = firstName;
this.lastName = lastName;
}
fullName()
{
return `${this.firstName} ${this.lastName}`;
}
}
class Person(val firstName: String,
val lastName: String)
{
def fullName(): String =
s"$firstName $lastName"
}
15. const personMap = new Map<number, Person>([
[10, new Person("Roger", "Moore")],
[20, new Person("James", "Bond")]]);
const names = new Array<string>();
for (const [key, person] of personMap)
{
if (key > 15)
{
names.push(`${key} = ${person.firstName}`);
}
}
val personMap = Map(
10 -> new Person("Roger", "Moore"),
20 -> new Person("James", "Bond"))
val names = for
{
(key, person) <- personMap
if key > 15
} yield s"$key = ${person.firstName}"