Learn JavaScript ES6 Modules in 6 minutes! 🚢

  Рет қаралды 10,716

Bro Code

Bro Code

6 ай бұрын

#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;
}

Пікірлер: 11
@BroCodez
@BroCodez 7 ай бұрын
UPDATE: (4 * PI * radius * radius) is for surface area of a sphere, not volume. I mixed up my formulas. (4 /3 * PI * radius * radius * radius) is for volume of a sphere. #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 /3 * PI * radius * radius * radius; }
@user-hz4jl9kf2h
@user-hz4jl9kf2h 6 ай бұрын
You've done fucking good job!
@ricardomoraes9850
@ricardomoraes9850 6 ай бұрын
Will you remake your JavaScript course? I like the way you teach 🙏🙏
@futuredoctor7148
@futuredoctor7148 2 ай бұрын
Why remake?
@fadi_mousa
@fadi_mousa 6 ай бұрын
Yor are a great teacher but 4 pi r*r is surface area of sphere the volume is 4/3 pi r*r*r 😊 thank you
@noelkitonga
@noelkitonga Ай бұрын
I now see where React and its many minions got all their super powers.
@xzex2609
@xzex2609 6 ай бұрын
one thing I didn't understand is that while mathutils.js is a module why in we put index.js with attribute of type ="modele" >?? I add an object to the packages.json to solve this
@victorr_olu
@victorr_olu 3 ай бұрын
how did you do this
@hunin27
@hunin27 6 ай бұрын
isnt volume: 4/3 * pi * r^3
@aimbot_user19
@aimbot_user19 6 ай бұрын
NO WAY!!!! I THOUGHT YOU QUIT!!!!
@xzex2609
@xzex2609 6 ай бұрын
(please help Bro) I Had this error in React too than it wants me to add an object in packages.json :: Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension , I couldn't find packages.json file so I made one on the directory and it worked , I think there must be a packages.json files for solving {'type' : 'module'} for all files with export ability that I don't know where it is . and the OTHER SOLUTION to renaming it .mjs file didn't work at all ( in the console of node js inside vscode ) I am sure people have my trouble and don't know where exactly must add the object {"type": "module"}
What is asynchronous JavaScript code? 💤
4:48
Bro Code
Рет қаралды 11 М.
Require vs Import Javascript
22:39
Monsterlessons Academy
Рет қаралды 75 М.
Increíble final 😱
00:37
Juan De Dios Pantoja 2
Рет қаралды 90 МЛН
Китайка и Пчелка 4 серия😂😆
00:19
KITAYKA
Рет қаралды 3,7 МЛН
JavaScript ES6 Arrow Functions Tutorial
9:32
Web Dev Simplified
Рет қаралды 816 М.
Javascript Modules | Export Import Syntax for ES6 Modules
17:14
Python Classes Tutorial #5 | Advanced Concepts
10:08
Aikonic
Рет қаралды 7 М.
Build JavaScript ROCK PAPER SCISSORS in 18 minutes! 👊
18:54
JavaScript ES6 Modules
7:39
Web Dev Simplified
Рет қаралды 444 М.
JavaScript DESTRUCTURING in 8 minutes! 💥
8:41
Bro Code
Рет қаралды 13 М.
The Async Await Episode I Promised
12:04
Fireship
Рет қаралды 1,1 МЛН
Start Using ES Modules Now
5:47
Engineer Man
Рет қаралды 24 М.
Increíble final 😱
00:37
Juan De Dios Pantoja 2
Рет қаралды 90 МЛН