Page 91 - Nodejs 교과서 개정2판
P. 91

§ Ӓܿ     FYQPSUT৬ NPEVMF FYQPSUT੄ ҙ҅



              8BSOJOH FYQPSUT ё୓ ࢎਊ द

           exports ё୓ܳ ࢎਊೡ ٸח module.exports৬੄ ଵઑ ҙ҅о ӵ૑૑ ঋب۾ ઱੄೧ঠ ೤פ׮  module.exportsীח যڃ

           ч੉ٚ ؀ੑ೧ب غ૑݅  exportsীח ߈٘द ё୓୊ۢ ࣘࢿݺҗ ࣘࢿчਸ ؀ੑ೧ঠ ೤פ׮  exportsী ׮ܲ чਸ ؀ੑೞݶ
           ё୓੄ ଵઑ ҙ҅о Րѹ ؊ ੉࢚ ݽٕ۽ ӝמೞ૑ ঋणפ׮

           exportsܳ ࢎਊೡ ٸח ё୓݅ ࢎਊೡ ࣻ ੓ਵ޲۽ GVOD KT৬ э੉ module.exportsী ೣࣻܳ ؀ੑೠ ҃਋ীח exports۽
           ߄Ե ࣻ হणפ׮

           exports৬ module.exportsীח ଵઑ ҙ҅о ੓ਵ޲۽ ೠ ݽٕী exports ё୓৬ module.exportsܳ زदী ࢎਊೞ૑ ঋ
           ח Ѫ੉ જणפ׮





           /PUF ™ ֢٘ীࢲ UIJTח ޖ঺ੌөਃ

           ֢٘ীࢲ thisܳ ࢎਊೡ ٸ ઱੄೧ঠ ೡ ੼੉ ੓णפ׮


            this.js
            console.log(this);
            console.log(this	===	module.exports);
            console.log(this	===	exports)
            function	whatIsThis()	{
            		console.log('function',	this	===	exports,	this	===	global);
            }
            whatIsThis();




            콘솔

            $	node	this
            {}
            true
            true
            function	false	true

           ׮ܲ ࠗ࠙਷ ࠳ۄ਋੷੄ ੗߄झ௼݀౟৬ زੌೞ૑݅ ୭࢚ਤ झ௏೐ী ઓ੤ೞח thisח module.exports ژח exports ё୓

           ܳ оܻఈפ׮  ژೠ  ೣࣻ ࢶ঱ޙ ղࠗ੄ thisח global ё୓ܳ оܻఈפ׮




         ੉ߣীח ݽٕਸ ࠛ۞য়ח requireী ؀೧ ঌইࠇद׮  requireח ೣࣻ੉Ҋ  ೣࣻח ё୓੉޲۽ requireח ё
         ୓۽ࢲ ݻ о૑ ࣘࢿਸ ыҊ ੓णפ׮  Ӓ઺ীࢲ require.cache৬ require.mainী ؀೧ ঌইࠁѷणפ׮


         WBS KTо ੓ח Ҕী SFRVJSF KTܳ ٟ݅פ׮
   86   87   88   89   90   91   92   93   94   95   96