WEBVTT

00:00.060 --> 00:00.510
OK.

00:00.840 --> 00:04.710
So it's time for a five minute crash course of note and Javascript.

00:04.710 --> 00:07.770
Obviously that's not enough time to even scratch the surface.

00:07.770 --> 00:12.940
But I'm just going to show you the basics of what you need to know for us to continue on with the course.

00:13.200 --> 00:13.770
OK.

00:13.950 --> 00:17.370
So back over in cloud 9 we will delete everything.

00:17.400 --> 00:19.660
Get rid of it so you can do that either.

00:19.670 --> 00:26.600
If you want to use a command line you can do use Ahram and armed dash R.F. or just highlight what you

00:26.600 --> 00:28.350
need to delete right quick.

00:28.400 --> 00:30.330
And where's that.

00:30.680 --> 00:36.260
And then we'll say yes to all you want to remove all of it and Humphrey now can get rid of some of this

00:36.260 --> 00:37.610
stuff.

00:37.610 --> 00:38.720
Perfect.

00:39.050 --> 00:40.180
Make some space.

00:40.190 --> 00:41.860
I'll bring this up a bit.

00:41.930 --> 00:47.660
Now all that we're going to do is make our first javascript file we can call it whatever we want.

00:47.720 --> 00:53.180
You can either use touch genius or what you know you don't have to call it app dodgiest where you can

00:53.180 --> 00:57.340
right click over here and click on new file.

00:57.380 --> 01:02.140
I'll do that one and I will call this oh I'll do it.

01:02.550 --> 01:04.090
It's a standard name.

01:04.570 --> 01:05.090
OK.

01:05.360 --> 01:07.220
And I won't recreate it down here.

01:07.220 --> 01:11.900
Now we'll open it up double quick and we'll add some javascript in here.

01:12.170 --> 01:17.570
So what I want to show you is this basic workflow with node that we kind of saw already we type some

01:17.650 --> 01:25.190
in a file we save it and then we execute the file with the command node space and then the name of the

01:25.190 --> 01:25.750
file.

01:26.000 --> 01:30.980
So it's very similar at least in principle to what we did with the sequel files where we had save a

01:30.980 --> 01:33.120
sequel file ending and as well.

01:33.350 --> 01:41.570
Put something in there a query then we would execute it using source and then some file name as well.

01:41.600 --> 01:43.150
Same idea.

01:43.520 --> 01:45.390
So I'm going to show you some very simple code.

01:45.410 --> 01:48.320
There's something called And again if you know this stuff.

01:48.320 --> 01:50.030
Feel free to skip it.

01:50.120 --> 01:55.220
Something called Constant Aag kind of the simplest possible commands you can do in my ask.

01:55.310 --> 01:56.720
It will just print something out.

01:56.900 --> 02:00.230
So we can do our basic hello.

02:00.440 --> 02:02.010
We don't need caps.

02:02.660 --> 02:03.760
Hello world.

02:05.780 --> 02:10.920
We'll put a semi-colon there which should seem familiar from my school at least.

02:10.920 --> 02:11.960
And let's start with this.

02:11.970 --> 02:18.870
Our first application very basic when all we need to do to execute is come down here and type node and

02:18.870 --> 02:27.780
the name of the file which we called app dot J.S. and it runs silly but it works OK.

02:27.870 --> 02:32.390
So that doesn't seem useful of course but it's something right.

02:32.550 --> 02:39.850
And to see kind of why a programming language would be useful let's at least do this 500 times.

02:40.110 --> 02:44.910
Maybe that's not useful but we can at least see how it's helpful at doing something that we can't do

02:44.910 --> 02:45.580
on our own.

02:45.900 --> 02:47.600
So we can create a simple loop

02:51.180 --> 02:54.710
will do less than five hundred.

02:54.780 --> 03:02.220
Now in my other courses this is like an entire video five or 10 minutes with exercises but not going

03:02.220 --> 03:03.360
to spend time on that.

03:03.360 --> 03:06.310
What this does is it says whatever's inside of here.

03:06.360 --> 03:07.880
Repeat 500 times.

03:08.190 --> 03:11.810
Basically this is a counter saying OK we're starting at zero.

03:11.880 --> 03:17.030
And every time through the loop we're going to add one to I which is what this does here.

03:17.250 --> 03:20.910
So we go 0 next time around 1 to 3.

03:21.000 --> 03:25.570
Keep going while it's less than five hundred as soon as it hits 500 we're done.

03:25.800 --> 03:26.180
OK.

03:26.280 --> 03:33.430
So if I just put that in there whatever's in these brackets here will happen 500 times.

03:33.540 --> 03:34.610
Let's do it now.

03:34.620 --> 03:40.170
One thing I could add that I probably should is this var key word it's just don't worry about it.

03:40.260 --> 03:43.190
But it's important to have it there.

03:43.290 --> 03:49.990
Now if I run it scroll up can see get hundreds of the world's Well 500.

03:50.010 --> 03:52.610
So imagine you might be wondering why you care.

03:52.740 --> 03:55.210
Well imagine instead of console log.

03:55.440 --> 03:59.470
What if we had insert a new user into the database.

03:59.790 --> 04:04.800
That would be a fantastic way to quickly see a database with a bunch of data.

04:04.800 --> 04:07.830
Remember how we had to do this obnoxious copy and paste.

04:07.860 --> 04:13.700
So I would give you a file you would copy and paste it like for the movies data and reviews areas these

04:13.710 --> 04:16.360
big files you have to copy and paste it in.

04:16.380 --> 04:18.970
It's an awful way of getting sampled data.

04:19.110 --> 04:21.990
Well we can use javascript to create data for us.

04:21.990 --> 04:24.120
So just a couple other things I'll show you.

04:24.320 --> 04:29.180
You know we can do math and basic things like five plus five.

04:29.640 --> 04:32.000
And I won't do this 500 times.

04:32.190 --> 04:35.970
We can comment things out selecting them and doing command slash.

04:35.970 --> 04:37.430
So that won't run anymore.

04:37.440 --> 04:39.900
So now I'm only running five plus five.

04:40.260 --> 04:41.670
You can see we get 10.

04:41.670 --> 04:45.920
One other thing to address is what what is node if you're not familiar with it.

04:45.970 --> 04:47.690
And that's actually a pretty common question.

04:47.700 --> 04:49.190
There's a bit of confusion about.

04:49.260 --> 04:50.190
No no.

04:50.220 --> 04:50.830
Yes.

04:50.880 --> 04:53.220
Which is what is called and regular Javascript.

04:53.220 --> 04:57.730
And what the difference is basically Javascript is a programming language was created first.

04:58.020 --> 05:03.010
It's been around for a while and it's existed as a language that you can use on the client side.

05:03.120 --> 05:10.190
So what that means is that back on this diagram there's a line right here not right now but imagine

05:10.190 --> 05:10.750
a line.

05:10.800 --> 05:17.040
This is the client side so I could write javascript code that did things over on someone like on my

05:17.040 --> 05:23.310
computer you could write code that would animate something or make a game or just add some pretty effects.

05:23.310 --> 05:25.610
That's not to say that it's not powerful.

05:25.680 --> 05:31.210
But traditionally it was used to decorate pages if you will and it had nothing to do with databases.

05:31.230 --> 05:32.660
It had nothing to do with servers.

05:32.850 --> 05:38.400
You would use another language over here like DHP and you would use javascript's on the client side

05:38.400 --> 05:46.170
of the front end but then node came around about five years ago now and what it is is an implementation

05:46.230 --> 05:51.600
of javascript written so that you can use it on the backend so that you can do things like this you

05:51.600 --> 05:58.060
can create a server with javascript instead of having to do it with Ruby or THP and you can talk to

05:58.060 --> 06:01.380
a database like any other server side language.

06:01.380 --> 06:09.240
So to summarize that node is javascript it uses basically the exact same syntax but you can use it on

06:09.240 --> 06:12.240
the backend which is what we'll be doing in this course.
