1 00:00:01,040 --> 00:00:01,760 Welcome back. 2 00:00:02,060 --> 00:00:10,850 It's time to learn Node J.S. now, no, we've kind of used it in previous videos, but we haven't really 3 00:00:10,850 --> 00:00:11,630 explained it. 4 00:00:11,900 --> 00:00:17,870 So throughout this section, we're going to learn what it is and finally use it to build a server. 5 00:00:19,590 --> 00:00:26,370 Now, we may have mentioned this before, but node is JavaScript that runs on your machine. 6 00:00:27,120 --> 00:00:34,140 You see, up until node was created, you could only run JavaScript in the browser because the browsers 7 00:00:34,140 --> 00:00:37,920 were the only ones that had a JavaScript engine like V8. 8 00:00:39,590 --> 00:00:48,080 And no GST was created with the V8 engine in order to be able to run JavaScript anywhere, including 9 00:00:48,080 --> 00:00:53,720 your computer, including our robots and anywhere as long as you had no gas. 10 00:00:54,380 --> 00:01:00,980 And as a matter of fact, we've been using node this entire time in our terminal when we ran commands 11 00:01:00,980 --> 00:01:04,910 that AMPM gave us like Create React app. 12 00:01:05,360 --> 00:01:07,270 Well, that was using Node. 13 00:01:07,280 --> 00:01:10,400 We were running JavaScript outside of the browser. 14 00:01:11,940 --> 00:01:16,830 And no gas is probably the most popular for building servers. 15 00:01:17,250 --> 00:01:23,940 It's really, really fast, and more and more companies are using it now as a backend server because 16 00:01:23,940 --> 00:01:26,340 of the way that it's built. 17 00:01:26,730 --> 00:01:32,970 No gas is probably the server of choice for any web apps or mobile apps out there that want to create 18 00:01:32,970 --> 00:01:34,320 an API or server. 19 00:01:35,390 --> 00:01:40,130 And it's also really, really good at building chat applications and real time communication. 20 00:01:40,970 --> 00:01:45,080 Anyway, as we've mentioned before, you probably should have this on your computer by now, but if 21 00:01:45,080 --> 00:01:47,860 not, you can download Node.js. 22 00:01:47,870 --> 00:01:49,940 I like using the Altius version. 23 00:01:50,900 --> 00:01:56,600 But as long as the version that you're using is higher than eight point nine point three, this demonstration 24 00:01:56,600 --> 00:01:58,050 will work for you. 25 00:01:58,070 --> 00:02:00,830 Notice really, really good at making sure that everything is compatible. 26 00:02:01,370 --> 00:02:07,790 Again, if you're using a Windows operating system, then Node provides that for you in the download 27 00:02:07,790 --> 00:02:08,479 section as well. 28 00:02:09,789 --> 00:02:15,760 And again, to check node, it's very easy, we just do note dash fee to see that we have it. 29 00:02:16,090 --> 00:02:20,620 And if you do have it, you'll have the version number printed for you on the console. 30 00:02:21,840 --> 00:02:27,360 One last thing before I show you some note commands, like I said before, note can be run anywhere. 31 00:02:27,570 --> 00:02:33,300 And one of my favorite things to do with note other than built servers is to actually create robots 32 00:02:33,300 --> 00:02:34,380 using JavaScript. 33 00:02:34,860 --> 00:02:41,670 This Johnny five is a JavaScript library that you can use with Node, and if you have something like 34 00:02:41,670 --> 00:02:42,780 a Raspberry Pi. 35 00:02:44,530 --> 00:02:52,900 It helps you build functions using JavaScript that robots can perform so highly, highly recommended. 36 00:02:53,200 --> 00:02:59,320 After this course, if you want to explore more, Johnny five is one of my favorite things, and it's 37 00:02:59,320 --> 00:03:06,940 surprising how easy it is to build a robot that does whatever you wanted to do just using JavaScript. 38 00:03:08,090 --> 00:03:10,070 But anyway, let's go back to note. 39 00:03:12,800 --> 00:03:20,240 In your terminal, if you actually type in Node and press enter, you'll see that the prompt changes 40 00:03:20,240 --> 00:03:20,540 now. 41 00:03:21,110 --> 00:03:27,020 And I can run node in the terminal if I do console the log. 42 00:03:30,670 --> 00:03:33,400 I get high if I do four plus five. 43 00:03:34,330 --> 00:03:38,980 I get nine and if I do bullion. 44 00:03:40,090 --> 00:03:40,630 Three. 45 00:03:41,170 --> 00:03:43,060 They spell the harangue bullion. 46 00:03:45,650 --> 00:03:47,150 Three, I get true. 47 00:03:47,810 --> 00:03:50,750 As you can see, we're just running JavaScript. 48 00:03:51,710 --> 00:03:53,210 But there is a bit of a difference here. 49 00:03:53,990 --> 00:03:58,080 If I type in window, I get a reference here. 50 00:03:58,100 --> 00:03:59,690 Window is not defined. 51 00:04:00,830 --> 00:04:02,570 And let me clear this a little bit. 52 00:04:02,960 --> 00:04:05,000 This is because when we run node. 53 00:04:06,460 --> 00:04:13,300 We don't have the window object, the window object was provided to us by the browser and as you know, 54 00:04:13,300 --> 00:04:15,910 note, well, there's no browser that's running it. 55 00:04:16,240 --> 00:04:19,120 Instead, note comes with something called global. 56 00:04:20,640 --> 00:04:26,970 And you can see that this global has just like the window object, had a bunch of things that we can 57 00:04:26,970 --> 00:04:30,810 use, but it won't have browser specific things. 58 00:04:31,870 --> 00:04:38,470 For example, we won't be able to have global sport fetch. 59 00:04:40,900 --> 00:04:45,880 It's undefined because, well, it doesn't exist that was provided to us by the browser. 60 00:04:46,540 --> 00:04:49,240 We also don't have the document object. 61 00:04:49,330 --> 00:04:55,060 If you remember, if I do document again, I get a reference error because, well, there's no document, 62 00:04:55,330 --> 00:04:56,900 so that's something to keep in mind. 63 00:04:57,250 --> 00:05:01,060 Node comes with its own properties and methods that we use. 64 00:05:01,600 --> 00:05:06,190 But other than browser specific things, we can do anything we want with note. 65 00:05:06,730 --> 00:05:10,600 One of the global objects that we have is something called process. 66 00:05:11,690 --> 00:05:20,180 If I press enter again, I have a ton of stuff, and in node process means this process, what I'm running 67 00:05:20,180 --> 00:05:24,200 right now in the terminal is the process, what the computer is doing. 68 00:05:25,800 --> 00:05:27,870 All right, and let's just clear this. 69 00:05:28,980 --> 00:05:31,680 Now if I do process Scott exit. 70 00:05:33,780 --> 00:05:37,830 I exit this process, and now I'm back to my terminal. 71 00:05:39,120 --> 00:05:45,870 Now that we have node in our power, we're going to start writing some scripts and show you how we can 72 00:05:45,870 --> 00:05:51,270 start writing actual JavaScript, not in the terminal, but in sublime text. 73 00:05:51,810 --> 00:05:52,860 I'll see you in the next video. 74 00:05:53,550 --> 00:05:53,910 Bye bye.