Understanding Types and Values

Modern JavaScript Learn JavaScript Fundamentals
3 minutes
Share the link to this page
Copied
  Completed

Transcript

In this movie, we're going to talk about types and values. Now computer programs work by manipulating values. We saw an example of that in some of the previous movies. For example, we put the first name, our first name and a variable and then put our last name in a variable. And then we put those two together. That's an example of manipulating values.

Now in order for language to manipulate the values, it must know the difference between the values. For example, the plus symbol, which is the operator we use to put the first name and last name together is also an operator that can be used with numbers to add numbers together. And so it's important for the language to know what values it's dealing with. Now, the kinds of values that are used in a programming language are referred to as types. So first, let's take a look at the different types. that are available in JavaScript.

First we have strings. We've seen some examples of strings. A name is a string. We have two examples here on the screen. Notice that 67 even though it's a number, because it is contained within quotes, it becomes a string, not a number. A string can also be a long sentence or a long paragraph.

It doesn't simply need to be one word, but it's anything that's contained between those those quotes. And it can be single quotes. The next type is a number. There's three examples of numbers there, 32 3.14, and negative 10. Those are all numbers. Notice how they differ from the 67.

In the previous example, it's not contained within quotes. Then we have Boolean, there are only two values for Booleans there is true and false and that is all where we string Numbers, you can have an infinite number of values with Booleans. There's only two values, then we have the type undefined and the type null. We'll deal with this in a little more detail later. But basically, undefined represents nothing and no represents nothing. The difference between the two is undefined is a state assigned by the system.

So if you declare something, but nothing no value is ever put into it, it's undefined. We're known as something that's declared by the computer by the program, you're declaring that there is no value in there. And we have symbols. Now symbols is a part of es six symbols we will not deal with in this particular course, but I want to make sure that you're aware of it that it's one of the types it's available in JavaScript. Finally, the last type I want to mention is objects. Everything else in JavaScript is an object.

So examples of objects are arrays, functions, JavaScript objects, all of those are objects. Now the six types above objects, those are all considered primitive data types. And then everything else is an object. Now the main difference between primitive data types and objects is that one's malleable. And one's not malleable simply simply means it can be changed. It's a programming term that you can change something.

Now, objects are malleable, they can be changed primitive data types are not. So the first six shown there are primitive data types. We're going to take a look now at manipulating or working with some of these data types, mainly strings and numbers.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.