1
00:00:00,540 --> 00:00:08,670
All right, so far we know two flavors, one, if we want to export one value, which is that module

2
00:00:08,670 --> 00:00:16,550
exports equal to that value and wherever we want to use it, we just import it equal to some kind of

3
00:00:16,550 --> 00:00:16,980
variable.

4
00:00:17,880 --> 00:00:22,320
Once we use that variable, we have access to that value.

5
00:00:22,800 --> 00:00:30,150
And the second flavor is if we have multiple values, then we simply set module exports equal to an

6
00:00:30,150 --> 00:00:30,600
object.

7
00:00:30,840 --> 00:00:34,390
And then in that object we set up the properties.

8
00:00:34,410 --> 00:00:37,860
However, there's also another way how we can do that.

9
00:00:38,190 --> 00:00:41,580
And essentially it is called export.

10
00:00:41,580 --> 00:00:50,520
As you go on the way, it looks like first I'm going to set up a new file and I'll call this six and

11
00:00:50,520 --> 00:00:52,320
I'll call this alternative.

12
00:00:53,260 --> 00:01:01,850
Flavor, again, I is really up to you, since that is the hardest thing in programming and I'm going

13
00:01:01,850 --> 00:01:03,400
to come up with one.

14
00:01:03,560 --> 00:01:04,030
All right.

15
00:01:04,420 --> 00:01:10,630
And I'm going to call these items, and that will be equal to item one and item number two.

16
00:01:10,990 --> 00:01:18,370
And then I'll set up a object and I'll second person is equal to a object.

17
00:01:18,370 --> 00:01:23,290
And they're surprised the prize will go with the name property and set it equal to Bob.

18
00:01:23,390 --> 00:01:30,730
I'm purposely adding multiple data types just so you don't think that we can only export variables or

19
00:01:30,730 --> 00:01:31,270
functions.

20
00:01:31,750 --> 00:01:40,840
And in here we have two options, either where we are setting up the value in this case items I simply

21
00:01:40,840 --> 00:01:45,280
go with module exports and then whatever is the name.

22
00:01:45,550 --> 00:01:47,680
And of course, in this case, I'm going to keep the items.

23
00:01:47,920 --> 00:01:55,420
But notice the syntax where instead of going with const items, I right away go with module exports.

24
00:01:55,600 --> 00:01:58,630
Or if you are a true rebel, you can do something like this.

25
00:01:58,630 --> 00:02:08,139
Module exports set up the property, for example, a single person, and set it equal to your person

26
00:02:08,139 --> 00:02:08,680
object.

27
00:02:08,979 --> 00:02:10,360
Why are able to do that?

28
00:02:10,360 --> 00:02:16,960
Because if you remember in the previous video, when we console log module exports, it was an object,

29
00:02:16,960 --> 00:02:17,230
right?

30
00:02:17,620 --> 00:02:18,740
So what are we doing here?

31
00:02:19,120 --> 00:02:24,220
We're setting up a property on that object and set it equal to honourary.

32
00:02:24,760 --> 00:02:29,070
And here I set up another property and just set it equal to a person.

33
00:02:29,080 --> 00:02:34,870
Keep in mind, of course, I can still write simply module exports and then the person.

34
00:02:35,320 --> 00:02:43,120
But since you might sometimes see this type of syntax as well, I wanted to cover that we save alternative

35
00:02:43,120 --> 00:02:44,140
flavor jars.

36
00:02:44,560 --> 00:02:51,190
And you're probably not going to be surprised that if we navigate to objects and in this case I will

37
00:02:51,190 --> 00:02:53,440
call this data because I'm getting a object.

38
00:02:53,440 --> 00:02:57,370
And on that object I have two properties and I need to come up with some kind of name.

39
00:02:57,700 --> 00:03:01,290
Now, as always, this name is really up to you.

40
00:03:01,900 --> 00:03:04,350
You can call it shake and bake.

41
00:03:04,630 --> 00:03:07,210
You can call it Uncle Bobby, whatever you want.

42
00:03:07,600 --> 00:03:10,410
My I'm going to go with generic data.

43
00:03:10,660 --> 00:03:12,490
We go with require again.

44
00:03:12,490 --> 00:03:16,870
We're looking for a file by the name of alternative flavor.

45
00:03:17,080 --> 00:03:20,860
In this case, I'm not going to do anything with it apart from cataloging.

46
00:03:21,160 --> 00:03:27,490
And if I navigate back to my integrated terminal, I can run the node app.

47
00:03:27,490 --> 00:03:31,720
Just now I have the items as well as the single person.

48
00:03:32,080 --> 00:03:41,260
Now, please keep in mind one thing where this syntax, whether the first line or on number six at the

49
00:03:41,260 --> 00:03:45,310
end of the day, does exactly the same like we're doing over here.

50
00:03:45,730 --> 00:03:52,420
Yes, the syntax is a bit different, but at the end of the day, you just make these values available

51
00:03:52,420 --> 00:03:54,780
somewhere else in your code.

52
00:03:55,150 --> 00:04:01,090
Now, just because I prefer this type of syntax, most likely throughout the course you will see this

53
00:04:01,090 --> 00:04:01,480
approach.

54
00:04:01,810 --> 00:04:06,340
But if you prefer this one instead, be my guest.

55
00:04:06,580 --> 00:04:11,680
At the end of the day, it is your application and you are the one who is going to be maintaining it.

