module.exports
-
[Node.js] module.exports 와 exports 차이언어/Node.js 2024. 4. 20. 15:34
결론부터 말씀 드리면 module.exports 와 exports 는 사실상 같은 동작을 합니다. exports 객체는 module.exports의 단축형태입니다. exports가 module.exports의 객체를 call by reference 방식으로 바라보고 있으며, 최종적으로 리턴값은 module.exports라는 것이다. export는 property(속성을 내보내는) 방식으로 사용 module.exports는 바로 사용 가능 call by reference 방식이란? 프로그래밍 언어에서 사용되는 개념 중 하나로, 함수에 인수를 전달하는 방법을 설명하는 용어이다. call by reference에서는 함수에 인수로 변수의 메모리 주소(참조)를 전달합니다. 이는 원래 변수의 값을 변경할 수 있게..