All right. 1
Welcome back guys. 2
In the last lesson we saw how we could use the alert keyword in javascript to create a pop up in our 3
browser and the pop up would say whatever is in between the two round brackets. In this case it would 4
be Hello. 5
Now how does the browser know which part of this code is actual code i.e. keywords like alert and which 6
parts of this line is the text that we want to display? 7
Well there’s something that we've added here that tells the browser that this is a string, and the secret 8
is of course these two little quotation marks because everything that they enclose gets interpreted 9
by the computer as a string so that it gets taken out of the code and gets interpreted as text. 10
And this is really important because all the code that we write is written with text, right, with characters 11
in the English alphabet. 12
And it's really important that the computer knows which parts are the code and which parts are the text. 13
And this is a great place to introduce you to something called data types because a string is exactly 14
that. 15
It's a data type. 16
It's a way of classifying data to tell the computer how the program intends to use the data. 17
In this case it's simply the text that we want to be displayed in our pop up and you will see this data 18
type across all programming languages and it's pretty much always called a string. 19
And that's because it's simply a string of characters just as you would have a string of pearls. 20
And in the coming lessons whenever I refer to string I'm always talking about text that's not meant 21
to be interpreted as code or just a string of characters. 22
Now there are other data types other than strings. 23
For example there are numbers, and numbers, because they have different symbols from the alphabet than 24
we use for code, 25
then we don't actually need any special symbols to tell the computer that this is a number. 26
We can just simply type the number. And finally, the last data type I want to show you is the boolean. 27
And this is the data type that describes data that is either true or false. 28
And we're going to be using a combination of all of these data types in order to create the programs 29
and the web sites in the coming lessons and modules. 30
So this really is the groundwork and it's the fundamentals of how all programming languages work. 31
So let's take a look at this in more detail. 32
I want you to open up your console so you can do that by going to View, Developer, Javascript Console, 33
and you'll see it show up down here. And, in the console, 34
you can do a number of things. So you can, for example, add numbers to each other. 35
So 2 + 3 equals 5. 36
And you get an output after you hit enter. You can also write the code that we wrote before which is the 37
alert keyword and that tells the browser that we want a pop up that says the output of 2 + 3. 38
So once I hit enter I will get a pop up that says 5. 39
Now I want to show you another keyword other than the alert, 40
and this is called typeof. 41
And this actually tells you what is the data type of whatever it is that you put within these round 42
brackets. 43
So, for example, if I put 23 in here, then I will get the output of, 44
this is a number, but if I wrote something like typeof my name inside some quotation marks, then I 45
get told that this is a string. 46
And finally, let's just, for completion sake, use a boolean, for example true, then I get told that this 47
is a boolean. 48
So in the coming lessons and modules we'll be using all of these different data types in order to create 49
our web sites and web apps. And understanding the fact that different pieces of data can have different 50
data types will be a foundation block towards building those web sites and web apps. 51
Now, in the next lesson we're going to talk about another foundation block for all programming languages, 52
which is the variable. 53
So for all of that and more, I’ll see you on the next lesson.