Wrapping the talk about variable
Congratulations chapter 2 is officially over, almost officially. Throughout this chapter we've met numbers, strings and Boolean variables. All these variables are called primitive data types. In this last lecture we do a quick recap so set you up for chapter 3.
Video Transcript
00:00Congratulations, chapter 2 is over. We're not going to learn anything new further than what we've done, although we'll talk a little bit about what data types are.
00:09So if you feel like you don't need a recap, you could jump right ahead to chapter 3, but just in case, let's go over everything really quickly together.
00:18We saw and worked with four specific built-in functions, and I want us to walk through them really quickly again to familiarize ourselves with them.
00:29The first one we've seen was the console.log, and we said we could really send into it anything we want, and we'll output it.
00:37So we could send into it a string, such as hello world, close that and just send it in, and we'll see that hello world output in our console.
00:47We could also send to it, if we want, we could send into it a number directly. If we want, we could send into it directly a boolean value.
00:57So that was the three different types of elements that we could send directly into our console that we know of so far.
01:05Now, all these console elements are really invisible to the user unless their console is open, so this is really used explicitly for debugging.
01:14Well, we also looked at the alert box, which I don't recommend using in a real project, where you could type here anything you want, such as error message,
01:23and we could close that and doing our JavaScript rule of closing and, you know, opening and closing every round bracket and putting your quotation mark before our text, both opening and closing.
01:36And if I click on enter, I will see my error message.
01:40The next thing that we saw was also our prompt box, and our prompt on the other hand, our prompt, we said, accepts two parameters.
01:51One is what, what was our question?
01:56And then we could set here to a default value of default value.
02:03And I'm just going through this quickly because you already met it.
02:05And in that case, we're going to get a prompt that asks us a specific question or tells us something and enables us to type in whatever we want.
02:12And we could approve it to send that information through, sending it into whatever variable we have running.
02:19Last but not least, we met the confirm box.
02:22While in the confirm box, we can't actually literally add anything into our element, but we could actually ask it to confirm.
02:29So we have a question here.
02:31We send it as a string again into this function.
02:34And then it asks us the question and we have a choice between agreeing to it or canceling out sending true or sending false back.
02:42And then we get that value back.
02:44But if we look in our source code, we'll see that for the confirm, we set it into our B custom because we're getting a boolean value for our prompt.
02:52We set it into once we set it into S name because we were getting a string back, which was a name.
02:58And on the other time, we used it as N because we're getting a number back, which was the number of value that we wanted to work with.
03:05So that's it.
03:06Those are the main big things that we learned in this chapter.
03:09We learned about using the alert, the prompt, the confirm.
03:13We've even learned about three different variable types.
03:16One was a boolean, another was a string, and last was a number.
03:21We've seen how to work with numbers by combining and duplicating dividing and so on and so forth with them.
03:28And we've also seen how do you combine text together by taking a text and adding to it something.
03:35That's it for us on this chapter.
03:37This chapter is over.
03:38And by the way, the holistic name for all these variable types that we've met so far is called primitive data types.
03:57Now, before we wrap up this completely, I want to talk a little bit more about data types.
04:03And it's not critical for you to know about it if you don't know any other programming language.
04:09Now, in general, we're going to talk about what primitive data types are once we see data types that are not primitive.
04:17In our case, the only data types that we know are number strings and booleans.
04:22Primitive data types in different languages are different.
04:26For example, if you program in Flash or ActionScript 3, there is a data type which is a number,
04:33but there's also a data type that is called integer, which would only accept full numbers, 1, 2, 3, 4, 5, 6.
04:40There is a floating number, which is a number that has 0.5, for example.
04:45There are numbers that are only positive numbers, such as you int, which is only positive you can't be negative.
04:51Now, all these types of don't exist in JavaScript.
04:54In JavaScript, there's only one number type.
04:56It's a number type, and it bundles inside of it all the different types of data types.
05:01We're not going to talk about why that is.
05:03That's just the reality.
05:05Every language has their own rules of what type of information they have.
05:09Same goes for strings.
05:11Some languages have a data type, a simple data type, that is just one character,
05:16while others have the full length of strings, like we have in JavaScript.
05:21Literally, we're only talking about JavaScript, but I want you to be familiar with the idea
05:26that every language has a little bit different rules, but the basic idea is similar.
05:31There's basic data types.
05:33And once we go in to talk about, after we finish with these primitive values
05:38and we move on to complex shapes, complex objects, then we're going to go back
05:43and talk about the difference between complex and non-complex items.
05:47But for now, all variables, as far as we are concerned, are primitive variables.
05:52I just want you to be aware of the fact that there's other types that we are going to explore
05:56in the future chapter in this title.
05:59Alrighty, so that's it for this chapter.
06:01I hope you enjoyed it, and we're going to see you in the next chapter
06:04where we continue exploring the world of JavaScript
06:07and continue creating really cool animations that will become cooler and cooler
06:10as we know more JavaScript.
06:12So see you there in next chapter 3.
