tubeshowcase●1,194,391 videos♡ My collection 0
← Learn to Code

Learn to Code06:05

Learn JavaScript ES6 Modules in 6 minutes! 🚢

Bro Code ↗

From the creator

#javascript #tutorial #course // ES6 Module = An external file that contains reusable code // that can be imported into other JavaScript files // Can contain variables, classes, functions ... and more // Introduced as part of ECMAScript 2015 update // ---------- index.js ---------- import {PI, getCircumference, getArea, getVolume} from './mathUtil.js'; console.log(PI); const circumference = getCircumference(10); const area = getArea(10); const volume = getVolume(10); console.log(`${circumference.toFixed(2)}cm`); console.log(`${area.toFixed(2)}cm^2`); console.log(`${volume.toFixed(2)}cm^3`); // ---------- mathutil.js ---------- export const PI = 3.14159; export function getCircumference(radius){ return 2 * PI * radius; } export function getArea(radius){ return PI * radius * radius; } export function getVolume(radius){ return 4 * PI * radius * radius; }

Published 2023-11-29 · Watch on YouTube ↗
Availability and playback restrictions are controlled by the original channel.

Keep exploring Learn to Code