내보내기 가져오기 모듈

4629 단어
Person.js

export class Person {
    constructor(name) {
        this.name = name;
    }

    sayHello() {
        console.log(`Hi, this is ${this.name}`);
    }
}


helpers.js

function algoExpert() {
    console.log('AlgoExpert is the best!');
}

export function fronendExpert() {
    console.log('fronendExpert is the best!');
}


module.js

import * as helpers from './helpers.js';
import * as person from './Person.js';

helpers.fronendExpert();

const conner = new person.Person('Conner');
conner.sayHello();




가져오는 다른 방법




import { fronendExpert, algoExpert } from './helpers.js';
import {Person} from './Person.js';

fronendExpert();
algoExpert();

const conner = new Person('Conner');
conner.sayHello();


좋은 웹페이지 즐겨찾기