The ability to reply to discussions is limited to PRO members. Want to join in the discussion? Click here to subscribe now.

Export Modules in Node.js

Export Modules in Node.js

5:50
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.
Watch this lesson now
Avatar
egghead.io

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.

Avatar
P. Envall

The wording "exports statement" in this clip is a little strange. One does an assignment to the exports object (or module.exports, as the case may be). To me, "statement" means something else.

In reply to egghead.io
Avatar
P. Envall

The wording "exports statement" in this clip is a little strange. One does an assignment to the exports object (or module.exports, as the case may be). To me, "statement" means something else.

meant to write "to a property on the exports object"

In reply to P. Envall
Avatar
Will

Thanks for the feedback. I'll keep it in mind for future lessons.

In reply to P. Envall
Avatar
George

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

Avatar
Will

True! Thanks for the input!

In reply to George
Avatar
David(JoonHo) Um

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

Avatar
Matt

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;
}
Avatar
Will

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

In reply to Matt
HEY, QUICK QUESTION!
Joel's Head
Why are we asking?