Skip to content

Instantly share code, notes, and snippets.

@elalaouifaris
Forked from zaiste/es6_modules.js
Created January 14, 2016 10:33
Show Gist options
  • Save elalaouifaris/6bf49188508c980ebfd5 to your computer and use it in GitHub Desktop.
Save elalaouifaris/6bf49188508c980ebfd5 to your computer and use it in GitHub Desktop.
AngularJS Workshop
// module 1
export const sqrt = Math.sqrt;
export function square(x) {
return x * x;
}
export function diag(x, y) {
return sqrt(square(x) + square(y));
}
// importing from module 1 : named
import { square, diag } from 'lib';
console.log(square(11)); // 121
console.log(diag(4, 3)); // 5
// importing from module 1 : all with prefix
import * as lib from 'lib';
console.log(lib.square(11)); // 121
console.log(lib.diag(4, 3)); // 5
// module 2
export default function () { ··· }
// importing from module 2
import myFunc from 'myFunc';
myFunc();
// module 3
export default class { ··· }
// importing from module 3
import MyClass from 'MyClass';
const inst = new MyClass();
function Person() {
this.age = 0;
setInterval(function growUp() {
this.age++;
}, 1000);
}
var p = new Person();
// ---
function Person(){
this.age = 0;
setInterval(() => {
this.age++;
}, 1000);
}
var p = new Person();
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Nukomeet AngularJS 1.x Workshop</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.1.1/foundation.min.css" media="screen" title="no title" charset="utf-8">
<style media="screen">
body {
padding: 20px 20px;
}
</style>
</head>
<body>
<!-- content goes here -->
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment