Jonas: So let's now write
our very first line of JavaScript code.
And for now we will do that in the browser developer tools.
So just to get started as quick as possible.
We will then switch to the code editor
that we just installed before in the next video.
So make sure to open up Google Chrome,
and then there are three ways
in which we can open up the Chrome developer tools.
First, we can hit command option J on the keyboard.
And that's on Mac.
So on Windows, that's gonna be ctrl+alt+J.
And so this will then open up this console that we see here.
So all of these tabs here are basically the developer tools.
but we are just interested in the console, okay?
Now another way of opening the developer tools
is by right clicking and then inspect,
which will bring us here to the elements tab,
and then from there we can go to the console.
And the third way,
and I'm showing you all of them,
because I know that are different people
like to do it in different ways.
So the third way is to come here to the Chrome menu,
and then in there we go to view, developer
and then JavaScript console, okay?
And so we're back to the JavaScript console.
And I'm increasing to font here a little bit
by hitting command plus,
and give it some more space.
Now this JavaScript developer console
allows us to write and test JavaScript code.
So it's very useful during development,
for example, to fix errors.
Now we don't write real applications, of course,
using this console.
But now just to get started,
let's use the console because it's a good and easy way
to just write some JavaScript here.
So let's write alert,
which is a so-called JavaScript function,
then open up parenthesis
and without a space between alert and the parenthesis,
and then we write a so-called string.
So which is basically text,
and let's write "Hello world."
So that's the standard way
of learning programming in any programming language.
Then, we write the closing parenthesis
and then let's hit return, or enter.
And you'll see,
that JavaScript gave us this popup window here
which has "Hello world" just as we typed here
in our string, in our code.
Great, so that's your very first line
of JavaScript code right there.
So any code that we write here and then hit return
will immediately get evaluated.
Okay, but of course we can do a lot more.
So let's write some more JavaScript code,
which of course you do not need to understand yet.
I just wanted to show some stuff that we can do.
We will go into how everything works
as we progress through this section, okay?
So just to experiment a little bit,
let's write a so-called variable.
So let's say let JS equals, amazing.
And so once more, we are basically writing a string here,
so a text,
and then we will do if
and open parenthesis, JS,
is equal to amazing,
then we want an alert window like we saw before
saying JavaScript
is fun.
And if I hit, now return
we get this window which says
JavaScript is fun, okay?
So again, I will explain all these concepts
and how all of this works here as we go through the section.
But for now I hope that you can see the logic
that we basically defined JS as being amazing.
And then here in the next line,
we said that if JS is equal to amazing,
then JavaScript should show us this alert window
with this text, okay?
And now we can also change JS to, boring,
hit return again.
And now let's copy this text here again.
So we want to run it again.
So I'm just copying it and pasting it here, okay?
So let's try that again.
And this time nothing happened.
And so that's because JS is now no longer amazing.
It is boring.
And so, in this case,
if JavaScript is amazing is not actually true, right?
Because it's boring now.
And so in this case, the alert window is not shown.
Now, there's also another way
of going to the previous command,
which is by hitting the up arrow on the keyboard.
So just like this.
And so we can see all the previous commands
that we used before.
Great.
Now another thing that we can do
is to do simple math operations.
Let's say just 40, plus eight, plus 23, minus 10, let's say.
Hit return,
and then here we get the result.
So basically we can use this as a calculator.
And I hope that you can see how useful
this is gonna become later down the road.
Okay, and that's it for now.
So I hope that this gave you a nice first taste
of the language and of everything that is ahead.
So if you want,
you can experiment a little bit more with this,
or you can move on right to the next lecture
where we will learn what JavaScript actually is.
So, see you there.