Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions chapter-02/07-es6-modules/01-es6-modules.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="minimum-scale=1.0, width=device-width, maximum-scale=1.0, user-scalable=no"/>
<meta charset="utf-8">
<title>ES5 Modules</title>
<script src="https://unpkg.com/[email protected]/babel.min.js"></script>
</head>
<body>
<h1>ES5 Modules</h1>
<p>Open the console</p>
<script type="text/babel">

import { print, log} from "./text-helpers";
import freel from "./mt-freel";

print("printing a message");
log("logging a message");

freel.print();

</script>
</body>
</html>
21 changes: 21 additions & 0 deletions chapter-02/07-es6-modules/02-es6-modules-import-alias.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="minimum-scale=1.0, width=device-width, maximum-scale=1.0, user-scalable=no"/>
<meta charset="utf-8">
<title>ES5 Modules</title>
<script src="https://unpkg.com/[email protected]/babel.min.js"></script>
</head>
<body>
<h1>ES5 Modules</h1>
<p>Open the console</p>
<script type="text/babel">

import { print as p, log as l} from "./text-helpers";

p("printing a message");
l("logging a message");

</script>
</body>
</html>
26 changes: 26 additions & 0 deletions chapter-02/07-es6-modules/mt-freel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

class Vacation {
constructor(destination, length) {
this.destination = destination
this.length = length
}

print() {
console.log(`${this.destination} will take ${this.length} days.`)
}

}

class Expedition extends Vacation {
constructor(destination, length, gear) {
super(destination, length)
this.gear = gear
}

print() {
super.print()
console.log(`bring your ${this.gear.join(" and your ")}`)
}
}

export default new Expedition("Mt. Freel", 2, ["water", "snack"]);
4 changes: 4 additions & 0 deletions chapter-02/07-es6-modules/text-helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

export const print = (message) => log(message, new Date());

export const log = (message, timestamp) => console.log(`${timestamp.toString()}: ${message}`);