Skip to content

Instantly share code, notes, and snippets.

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 IgnaciodeNuevo/5583f59cc1e5a1981f6f1d77ac2d293f to your computer and use it in GitHub Desktop.
Save IgnaciodeNuevo/5583f59cc1e5a1981f6f1d77ac2d293f to your computer and use it in GitHub Desktop.
// Ejemplo 1 - named export: lib.js
export const sqrt = Math.sqrt;
export function square(x) {
return x * x;
}
export function diag(x, y) {
return sqrt(square(x) + square(y));
}
// Ejemplo 1 - named export: main.js
import { square, diag } from 'lib';
console.log(square(11)); // 121
console.log(diag(4, 3)); // 5
// Ejemplo 2 - default export: myFunc.js
export default function () { ... };
// Ejemplo 2 - default export: main.js
import myFunc from 'myFunc';
myFunc();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment