Created
June 11, 2019 16:34
-
-
Save IgnaciodeNuevo/5583f59cc1e5a1981f6f1d77ac2d293f to your computer and use it in GitHub Desktop.
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
// 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