Skip to content

Instantly share code, notes, and snippets.

@machal machal/index.html
Created Mar 25, 2020

Embed
What would you like to do?
ES6 modules basic demo for vzhurudolu.cz
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>
ES6 modules demo
</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script type="module" src="script.js"></script>
</head>
<body>
<main id="main" role="main" class="content">
<h1>
ES6 modules demo
</h1>
<p>
Open browser console.
</p>
</main><!-- /.content -->
</body>
</html>
// Vychozi export:
export default function() {
console.log('Default function')
}
// Export konsstanty:
export const hello = 'Hello!'
// Export funkce:
export function foo() {
console.log('foo');
}
// Funkce, ktera neni exportovana a zvenci je nedostupna:
function bar() {
console.log('bar');
}
// Importujeme:
import * as module from './module.js';
// Pouzivame:
module.foo();
console.log(module.hello);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.