OK.
So it's time for a five minute crash course of note and Javascript.
Obviously that's not enough time to even scratch the surface.
But I'm just going to show you the basics of what you need to know for us to continue on with the course.
OK.
So back over in cloud 9 we will delete everything.
Get rid of it so you can do that either.
If you want to use a command line you can do use Ahram and armed dash R.F. or just highlight what you
need to delete right quick.
And where's that.
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
stuff.
Perfect.
Make some space.
I'll bring this up a bit.
Now all that we're going to do is make our first javascript file we can call it whatever we want.
You can either use touch genius or what you know you don't have to call it app dodgiest where you can
right click over here and click on new file.
I'll do that one and I will call this oh I'll do it.
It's a standard name.
OK.
And I won't recreate it down here.
Now we'll open it up double quick and we'll add some javascript in here.
So what I want to show you is this basic workflow with node that we kind of saw already we type some
in a file we save it and then we execute the file with the command node space and then the name of the
file.
So it's very similar at least in principle to what we did with the sequel files where we had save a
sequel file ending and as well.
Put something in there a query then we would execute it using source and then some file name as well.
Same idea.
So I'm going to show you some very simple code.
There's something called And again if you know this stuff.
Feel free to skip it.
Something called Constant Aag kind of the simplest possible commands you can do in my ask.
It will just print something out.
So we can do our basic hello.
We don't need caps.
Hello world.
We'll put a semi-colon there which should seem familiar from my school at least.
And let's start with this.
Our first application very basic when all we need to do to execute is come down here and type node and
the name of the file which we called app dot J.S. and it runs silly but it works OK.
So that doesn't seem useful of course but it's something right.
And to see kind of why a programming language would be useful let's at least do this 500 times.
Maybe that's not useful but we can at least see how it's helpful at doing something that we can't do
on our own.
So we can create a simple loop
will do less than five hundred.
Now in my other courses this is like an entire video five or 10 minutes with exercises but not going
to spend time on that.
What this does is it says whatever's inside of here.
Repeat 500 times.
Basically this is a counter saying OK we're starting at zero.
And every time through the loop we're going to add one to I which is what this does here.
So we go 0 next time around 1 to 3.
Keep going while it's less than five hundred as soon as it hits 500 we're done.
OK.
So if I just put that in there whatever's in these brackets here will happen 500 times.
Let's do it now.
One thing I could add that I probably should is this var key word it's just don't worry about it.
But it's important to have it there.
Now if I run it scroll up can see get hundreds of the world's Well 500.
So imagine you might be wondering why you care.
Well imagine instead of console log.
What if we had insert a new user into the database.
That would be a fantastic way to quickly see a database with a bunch of data.
Remember how we had to do this obnoxious copy and paste.
So I would give you a file you would copy and paste it like for the movies data and reviews areas these
big files you have to copy and paste it in.
It's an awful way of getting sampled data.
Well we can use javascript to create data for us.
So just a couple other things I'll show you.
You know we can do math and basic things like five plus five.
And I won't do this 500 times.
We can comment things out selecting them and doing command slash.
So that won't run anymore.
So now I'm only running five plus five.
You can see we get 10.
One other thing to address is what what is node if you're not familiar with it.
And that's actually a pretty common question.
There's a bit of confusion about.
No no.
Yes.
Which is what is called and regular Javascript.
And what the difference is basically Javascript is a programming language was created first.
It's been around for a while and it's existed as a language that you can use on the client side.
So what that means is that back on this diagram there's a line right here not right now but imagine
a line.
This is the client side so I could write javascript code that did things over on someone like on my
computer you could write code that would animate something or make a game or just add some pretty effects.
That's not to say that it's not powerful.
But traditionally it was used to decorate pages if you will and it had nothing to do with databases.
It had nothing to do with servers.
You would use another language over here like DHP and you would use javascript's on the client side
of the front end but then node came around about five years ago now and what it is is an implementation
of javascript written so that you can use it on the backend so that you can do things like this you
can create a server with javascript instead of having to do it with Ruby or THP and you can talk to
a database like any other server side language.
So to summarize that node is javascript it uses basically the exact same syntax but you can use it on
the backend which is what we'll be doing in this course.