Enjoy free content straight from your inbox 💌
00:00
JavaScript only has a few primitive data types, and we've already used one primitive, which is the string in our simple log messages, and we will uncover the others in this lesson. Now, all the strings that we have created up to this point, we have used the single quote character. We can actually create strings within JavaScript using the double code as well. And at runtime, there is no difference between these two. It's simply a matter of preference. I personally prefer to use single coats wherever possible. Now, if the string that you're going to write contains a single coat on the inside, it is recommended that you use a double coat on the outside. And similarly,
00:35
if you have a string that contains a double coat on the inside, then we recommend that you use a single coat on the outside. Now, you can actually put a single coat inside a single coat by using an escape character, which is backslash within JavaScript, and then using the single coat that way. And similarly, within a double coded string, you can place a double coat by using backslash double coat as we have done in this example. Now, another primitive data type that exists within JavaScript is the number data type. And this is actually always a 64 bit floating point. So of course we can use it for intes,
01:08
but the same data type supports fractions as well. And this is actually a signed value, which means that we can have positive as well as negative numbers within JavaScript. Now, because the number data type is a 64 bit value, there is an upper limit on the integers that we can store safely within this. But if you want to store integers, which are as large as we want, for example, a Google value, we can do that with a big inter type that is provided by JavaScript. To present a big value within JavaScript, we simply write our integer and then add the suffix of the character N. Now, of course, because it doesn't have a fixed precision,
01:44
it is not going to perform as nicely as the number data type. So only use it if you really need to. A key to type within JavaScript to which plays a critical role in conditional logic is the bullion datatype. And this only has two possible literal values, which are either the literal true or the literal false. Undefined within JavaScript is a special value and a datatype, which is the value that the JavaScript runtime will return when a variable hasn't been initialized. Another primitive value within JavaScript is the value null, and this is a value that JavaScript developers will use to denote a value that isn't present. For example,
02:19
if you ask a function for a user profile but the user isn't currently logged in, we can instead choose to return null to denote that we have no user to return. We will discuss the differences between ANU and Undefined and how we can simplify these concepts in much greater detail later on. And finally, we have a symbol, which is a TE type that you are very unlikely to use yourself, but exist as a part of core JavaScript to internally make things like it ripples possible. The symbol type allows these internal implementations from leaking out to our normal code base. And that's it.
02:53
This is a nice tea sheet of all of the primitives that exist within JavaScript. Now that we know what we have to look forward to, we will discuss lots of details of all of these primitives in their own dedicated lessons.