Export Modules in Node.js

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
George
~ 8 years ago

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

Will Button
Will Button(instructor)
~ 8 years ago

True! Thanks for the input!

David(JoonHo) Um
David(JoonHo) Um
~ 8 years ago

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

Matt Batman
Matt Batman
~ 8 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 Button
Will Button(instructor)
~ 8 years ago

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