Skip to content
This repository was archived by the owner on Nov 23, 2024. It is now read-only.

Latest commit

 

History

History

modules

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

Modules

Named Exports

named_lib.js:

export const sqrt = Math.sqrt;

export function square(x) {
	return x * x;
}

export function hypotenuse(x, y) {
	return sqrt(square(x) + square(y));
}

named.js:

import { square, hypotenuse } from 'named_lib.js';

console.log('2 ^ 2 =', square(2));
console.log('3 ^ 2 + 4 ^ 2 = ', hypotenuse(3, 4), '^ 2');

Default Exports

default_foobar.js:

export default class Foobar {
	constructor() {
		this.foo = 'bar';
	}
}

default.js

import FooBar from 'default_foobar.js';

let foobar = new FooBar();

console.log(foobar, foobar.constructor.name);