Welcome back, ladies and gentlemen, into this lecture, we're going to talk about JavaScript types
and there are seven different JavaScript types.
Now, we're not going to cover all of them, but we're going to cover the first three no strings and
booleans.
Then in future, we will cover undefined, no symbol and objects in Y say, in future.
Well, because for these four or five, six and seven, we need to have a background knowledge for in
order to understand them.
That's the only reason I don't want to confuse you from the beginning of this section.
OK, now in order to follow me in this section, it is preferrable for you to have installed a text
editor or a code editor.
So I'm going to use voice code now.
How you can install viscose so you can type on Google vehicle and code that visual studio, that will
be the link that you want to visit.
And inside here, you can download for your for your operating system so you can install it for me.
I have already done it.
And it's for Mac and you.
If you're using windows, it will here, it will say for Windows.
OK, now some students will ask me why I'm telling you this again, because in some of the other sections,
I would probably say that you need to have installed a.
Well, the thing is that the students will skip some of the sections in when they see me using something
they haven't installed on their machines, they will start asking me questions.
That's the only reason now why I'm using Vasko throughout this course, because it's very lightweight
and it's very supportive.
It has a lot of extensions here.
Right.
And also building it, you can run and debug and it's Intellisense.
Very good.
Now, you don't know.
You don't need to know everything of this.
OK, so why I'm going to use this code one more time is because there I will want to write JavaScript
code here and save it in files.
So those files after that, you can access them and you can change them.
You can modify them, you can refresh your memory.
You can do your exercise.
That's the only thing.
Now, one more thing that I want to show you is that you can run the JavaScript code even in your browser.
Right.
So if you open Google dot com and if you inspect it, you will see here a console tab.
So if you go in the console tab now here you can write a code.
For example, let's do basic mathematical operation nine plus six.
That will be 15.
Right.
So you need to hit, return or enter because before it was light blue, four in my browser, for example,
here, this is 13.
But when I hit return on Macs or enter in windows, you will see this as a dark blue.
OK, that is pretty much what I want to show you.
Now, how are we going to do this?
First things first, you need to have on your desktop to see to download these JavaScript Genesis file
folder and in this directory here, I do have two things.
Final will contain all of those lecture's exercises, solutions.
But Starger will be empty.
And I'm going to do I'm going to start with the starter.
Right.
But you will need the final one in order to see all of the exercises.
So I want you after each and every lecture to go there and to see if that lecture has exercise and do
them.
And also there are solutions if you are stuck.
Very good.
I'm just do I mean, shift your folder on your desktop.
So mine is on desktop.
So here I'm going to say open folder.
Good.
I'm going to navigate to desktop starter hit enter.
This is how you use this code.
Nice.
So inside here we're going to create a file.
There is a plus symbol or right.
Click new file I'm going to use here.
I'm going to create index that HTML file in here, start typing doc he tap and it will give you the
entire document.
Now the title you can change the title, whatever title you want.
For example, just put it here.
Java script fundamentals.
Very good.
And in the body you can type each one tack and say OK, say again, JavaScript, Genesis.
Fundamentals are very good now.
That is pretty much what I want you to have in this file, so I'm going to use this one right.
And so probably you need to install the live server.
So go here on the extension step in heat like server.
And here it is, lunch mine has already been installed, but you will see here install.
Right.
So install that one.
If you need to close your viscose, close it just to restart it.
And you're good to go.
So I need this live server.
So here you can actually activate this life server, go right.
Click and open with live server or there is a shortcut.
Good.
Just open with life server and here it is, JavaScript Genesis Fundamentals.
This is coming from the H1 track that we wrote.
OK, now what I'm going to write here, another file.
Let me do it like this.
And you called lecturer.
Um, yeah, lecture one, dash one, that is this how are we going to name our lectures?
And this lecture is a JavaScript file.
Now, I just want to tell you that we do have a couple of ways how we can write JavaScript in our browser.
And the first thing is that we can do external files.
This is called external files.
But in order for this to work, I am going to tell you that we need to load them here.
So first we need to say script and we need to close this one.
Now, in the script that we have source and the source will be our current directory, not forward slash.
And that will be lecture one.
That J is very good.
And also we need to specify the type.
So Browser will know what to expect that that will be text and forward slash JavaScript, JavaScript
cuz now our JavaScript file, external JavaScript file is connected with this file here.
Right.
So there's other ways, but they're very basic.
I'm going to tell you in future you don't have to worry about it.
Right.
OK, now about JavaScript times, you can make a comment in JavaScript to forward slash and type JavaScript
types.
OK, now the first one that I want you to know is called the number.
So why is this very useful?
OK, this is one of the basic ones.
So with numbers, we can do basic math operation, for example.
We can just calculate how much is three plus seven.
OK, just do it.
Three plus seven semicolon and put a semicolon there.
Save it.
Or if you don't see me.
So here there is a bubble that means they have and save it.
No.
So now you need to also before checking your code, you need to save it.
So control s or command as in as is or control as in windows and that will save the file.
So there is no bubble there.
Right.
But now if you go here and if you refresh if you.
Right.
Click inspect.
In the console, there is nothing there in why's this before, remember, we just rode three plus seven
and it would give us the result.
But now I'm using the direct console here, this terminal here.
But in code, I don't have access to that.
So if you if you want to print out something to the browser here, which I can just delete it here,
let me just delete like that.
OK, so I need to write console console that log and put this one in brackets.
Now save it again and just go back here.
And here it is.
You do have 10 actually with live server.
You don't have to you don't have to refresh because it's going to work out comedically.
So with numbers we can do basic maths operation.
What else we can do?
Let's try something else.
Let's cancel the lock loops console.
So we use console the log every time we want to show something.
Right.
So ten minus nine, save it.
Right.
A couple of them console that log.
Not long, and here we are going to say 10 times three.
So let's divide something on the log, divide 20.
Divided by five.
OK, now save it, go back to your browser and you will see that I have 10 one 30 and for good for it's
coming twenty divided by five.
It's for ten times three is going to be thirty.
And this will be one.
And the first one will be ten.
OK, so if you want to write it, we can achieve the same thing here.
Ten times three it will be equal.
Thirty, ten minus nine it will be one in twenty.
Divided by five it will be four in.
How does this leave.
A server is working.
It will create a new URL.
This will be our local localhost actually our local machine and it will give us a port.
Maybe you're going to have a different port.
It doesn't matter in the HDMI is the file that I've created.
This one so you can hear here, exclamation mark, save it again.
And there you go.
The changes are already there.
And plus everything that we have done here in this is also printed out here.
Right.
OK, now, so let me quickly show you something else so we can do more complex operations like using
brackets or small brackets.
So console's along, for example, more complex operation is five minus two that will be multiplied
by by four minus.
Let's say to right, maybe that's not a good example, let's do it here, six, six, minus two.
So how this will work?
Well, if you know, Max, these first six minus two will be calculated, it will be four, then four,
minus two.
It will be calculated, it will be two.
And after that, whatever it's in the brackets, we can multiply it right.
So we can just six minus two, four times four.
So we can't we first need to work in the brackets and after that, just to calculate this one.
So save it.
So this should be four times two.
Should be eight.
Right.
And here is the result.
That is cool.
So we can do a more complex math functions here right now.
Let's talk about module.
Now, what is module?
Well, module gives you the reminder.
So let's write in the console.
So for this, I'm going to show you in the console.
Right, just to make just to make you practice that we can even use the condom.
So 16 Modula.
And seven, and that will give me to why?
Well, seven can be contained two times.
So two times, two times seven it will be 14 and 16, minus 14 is two.
So Modula will give us the reminder, right.
The reminder of 16.
So how many times seven can be contained in 16 times and two times 17.
So let's do this two time seven, not 17.
It will be 14.
So 14 minus 16.
That will give us the reminder.
So that is how we can use model right now.
That is pretty much with numbers.
Let's do the second JavaScript type and that will be string.
Now, what are strings?
So string is text in JavaScript needs to know if you are writing text.
And for this we need to use single or double quotes.
So that log and let's say I just want to print out my name.
Rick.
Good.
Now use single quotes, but you can use double quotes.
Let's see if it is Rick.
Now what we can do, we can cancel out my last name.
Let's use double quotes.
It's not going to change anything.
Make sure that when you use double quotes here, you need to use double quotes at the end.
So save it.
Here it is.
Now we can do something more interesting.
Let's do cancel the log.
So strings are very interesting to you.
So I'm going to say Rick here, plus Lewski, my last name.
And so this here is not consider as a mathematical symbol.
So this here is considered as concatenation.
And what it will do, it will it will combine it will actually glue Rick in Sokolsky together so those
the two strings will be attached one to each other.
And this is not good.
But what we can do, we can fix it.
What are we can do space here that will fix it.
Right.
Or we can get.
With space here, that will fix it, but sometimes you will see that some people are doing this.
Should they making an empty string here, right, so it's a space between but again, they need to use
the plus sign to concatenate with this one.
So the empty string will be concatenated with the first part, right.
This one.
But also the empty strings need to be concatenated.
Second part.
So save that and it will yield the same result.
Very good.
But.
So I used single quotes, but what if I want to do another quote inside?
So, for example, I own something.
So it's Rick's car, for example.
Let's do it.
Cancel that law and let's write Rick's.
Like that, and it's not allow me a car, should I have it here, so let's change this to double quotes
here.
Nice.
So this should work, but in the past it wasn't working because I use double quotes and single quotes
together, but if I use single quotes, then I do have a real big problem.
Now, why do we have a real big problem?
Well, in JavaScript, we can use something that, Wolf, will ignore this quote.
So the solution is to use backslash.
So we use backslash here.
And what we are basically saying to the compiler, OK, what's after the backslash consider is a normal
stream so that now the S this one.
Will be considered as normal, so riska, no more problems, right?
So.
By using the backslash, we can escape the quote and we can tell the compiler to ignore it and just
want to use the tactic to be included.
So that's why we use we need to use the backslash.
OK, now, another awesome scenario here.
I forgot the semicolon.
Make sure that you write semicolons.
It will work without semicolons, but it's always good at the end of the expression to write semicolons.
OK, now let's consider one awesome scenario.
What we think will happen if we try to combine numbers, something that we have done here and strings.
So cancel that lot.
Let's do it like this.
So let's say thirty three plus years now save it and let's go back here and it's saying thirty three
years, even if I put here space, still going to be thirty three years.
Right.
So why this is happening.
Why this result.
Well JavaScript will convert the number to a string.
This number two, a string one, because the plus sign will tell the JavaScript compiler, OK, we have
no in the string and the plus side probably means concatenation.
And that's why it will glue this the same as we did here.
Right.
So that is pretty much it.
So this plus sign doesn't mean mathematical operation in this because we don't have two numbers.
And it say because we do have a string together with a number, let's do a concatenation.
So it doesn't matter what you're going to put in, it's going to be considered as concatenation.
That is pretty much it.
Now, the thirty three it's not.
No, here it is.
It's a different color.
It's converted back to a string, so it's automatically converts 33 to string because it's not addition.
It's concatenation and that depends on the circumstances.
Now what if we do another scenario?
Copy this.
Well let's put here thirty three minus just like this.
What if I have here a number in quotes that is considered as a string.
Right.
Save it.
But let's see what will happen.
Wow.
Something strange.
Now I do have a blue twenty three.
That means it's a number in why this is happening.
Well we don't have anything for concatenation.
The plus sign can be used for mathematical operations like this, but also when we try to glue or attach
the strings to each other.
But here with the minus there is a different story.
The compiler will say, OK, whatever you have in the bracket, just consider it to be as a number because
we don't use no minus or this symbol here for concatenation.
And that's why it will convert this string to a number.
And yeah, we will have back and no result.
Now, the last thing that I want to discuss today is.
William JavaScript, that's so boolean is also true or false, so Boolean is used by our computers.
If you have done some EITE qualification, you will know that the entire computer code is written using
ones and zeros.
So.