Theme
Primary Color
Lesson 38

Modules Part 1 Export & Import

محتوى الدرس

app.js
// Method One

export const a = 1;

export let myArray = [1, 2, 3, 4, 5, 6];

export function sayHello(name) {

  return `Hello ${name}`;

}

// Method Two

const a = 1;

let myArray = [1, 2, 3, 4, 5, 6];

function sayHello(name) {

  return `Hello ${name}`;

}

export {
  a,
  myArray,
  sayHello
}
main.js
/*
  Modules Part 1 Export & Import 
*/

import { a, myArray, sayHello } from './app.js';

console.log(a);
console.log(myArray);
console.log(sayHello("Osama"));

for (let number of myArray) {

  console.log(number);

}