Skip to content

Latest commit

 

History

History
22 lines (17 loc) · 554 Bytes

2.4-Modules.md

File metadata and controls

22 lines (17 loc) · 554 Bytes

Modules are stored in files.

//------ 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));
}

//------ main.js ------
import { square, diag } from ‘src/lib';
console.log( square(11) ); // 121
console.log( diag(4, 3) ); // 5

Ej1: NotWorkingExample