Skip to content

Instantly share code, notes, and snippets.

@muratbaseren
Last active December 7, 2019 20:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save muratbaseren/719f9c57d4c76c45049817f07f5f691a to your computer and use it in GitHub Desktop.
Save muratbaseren/719f9c57d4c76c45049817f07f5f691a to your computer and use it in GitHub Desktop.
ES6 Modül Kullanımı
// export ile 2 adet metodu dışarıya açıyoruz.
export const topla = (x, y) => x + y;
export const cikar = (x, y) => x - y;
// math.js dosyasını uzantısı ile import ediyoruz.
// uzantının yazılması önemliymiş..
// içerisindeki metotlara erişmeyi sağlıyoruz.
import { topla, cikar } from './math.js';
console.log(topla(1, 3));
console.log(cikar(5, 2));
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<!-- type ifadesi önemliymiş yoksa kodlar çalışmıyor. -->
<!-- yazılan modlüllerin sayfaya eklenmesi -->
<script type="module" src="es6sample.js"></script>
</head>
<body>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment