ES6 modules basic demo for vzhurudolu.cz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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'); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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