Export Modules in Node.js

InstructorWill Button

Share this video with your friends

Send Tweet

In this lesson, you will learn the difference between the exports statement and module.exports. Two examples are demonstrated, each accomplishing the same task but one using export statements and one using module.exports. You will also learn the basic thumb rule to identify which is appropriate for your current needs.

George
~ 8 years ago

To be concise you can pass in the parameter var circle = require('./circle')(4) rather than declaring a myCircle

Will Buttoninstructor
~ 8 years ago

True! Thanks for the input!

David(JoonHo) Um
~ 7 years ago

For Korean engineers, I found a useful info about this lecture. (written in Korean) http://programmingsummaries.tistory.com/340

Matt Batman
~ 7 years ago

Thanks for the great course!

I believe there's a typo in the code snippet companion for the video (not in the code of the video itself) with PI versus Pi.

exports.circumference = function(r){
  return 2 * Pi * r;
}

should be:

exports.circumference = function(r){
  return 2 * PI * r;
}
Will Buttoninstructor
~ 7 years ago

You are correct. Nice catch, Matt. We'll get it updated.