[Node.js] exports, module.exports의 차이점

김민재·2023년 10월 31일

Node.js

목록 보기
2/36

exports

  • exports를 통해 밖으로 내보낼때는 익명함수를 사용하는데 객체(함수 자체)를 내보낸다.
  • 사용법: add.add(1,5);
exports.add = function (a,b){
			return a + b	}

module.exports

  • module.exports를 통해 밖으로 내보낼때는 함수 자체를 내보낸다.
  • 사용법: add(1,5);
function add(a,b){
	return a + b;
    }
    module.exports = add
profile
개발 경험치 쌓는 곳

0개의 댓글