node.js_exports

BABY CAT·2022년 9월 27일
0

node.js

목록 보기
6/18

1. callee n caller

ㄱ. 콜리

//콜리 불림당하는 파일  콜러한테 호출당하는프로그램

exports.randInt = function(from,to){
   return Math.floor(Math.random()*(to-from+1)+from)  // floor 소수값 버림
   //??return Math.ceil(Math.random()*(to-from)+from) // ceil 은 올림
}
exports.circleArea = radius => Math.PI *radius *radius ;

require("./11.callee").circleArea()
require("./11.callee").randInt()
로 콜

A. 콜리 변형

module.exports={
   randInt:  function(from,to){
   //function randInt(from,to){ // X  
      return Math.floor(Math.random()*(to-from+1)+from)  // floor 소수값 버림
   },
   circleArea: function(radius){

   return Math.PI *radius *radius; 
   }
} 

ㄴ. 콜러

// 콜러 호출을 하는 프로그램  콜리를호출

const myModule = require("./11.callee");

for(let i=0; i<5; i++){ //5번실행
   console.log(myModule.circleArea(myModule.randInt(1,10)))
} // 마이모듈속11.콜리파일속에있는 서클에리어 랜드인트 함수를 콜

end

0개의 댓글