24 Data types in JavaScript

Last updated on July 13th, 2020 at 11:15 am.

24 Data types in JS - JavaScript Tutorial 2018

This video is taken from the full course that will teach you HTML, CSS, Programming concepts and Javascript .

Transcript :

Hi, and welcome back.

So we’re going to start looking at data types in JavaScript.

So as you know, as you already know JavaScript is a loosely typed language.

That means that it is not as strict as certain statically typed languages.

So when it comes to data types, most of the work will actually befall on you to make sure that the data that gets into the system, the data that you get from the user, is the right kind of data.

So all of that will befall on you as a programmer.

What are the data types that we have in JavaScript? The primitive data types that we have in JavaScript, so the primitive or the primary data types that we have in JavaScript are ‘number’.

So a ‘number’, that can be 1, 1.2, -10.

So, this is a primitive data type.

Number, any kind of number, that is the first primitive type that we have in JavaScript.

And then we also have ‘strings’.

So ‘strings’, ‘strings’ are characters.

Maybe you want to put a word in there, you want to say ‘Hi, How are you?’, that can be represented by a string.

So we do have numbers, then we have strings, and then we have the ‘boolean’ type.

Now the ‘boolean’, this represents 2 values – True or False.

So this is used to represent whether a value is true or false.

You’ll see things related to the boolean type when we start looking at conditional statements.

Things like ‘if’, ‘if(x<y)’, then do whatever is inside the curly braces.

You’ll see about the boolean type come in to play in this kind of statements.

So the boolean type has two values only.

It can either be true, or it can be false.

And then we have the NULL.

Now basically the NULL, this is, this is an object that has no type and has no value.

So, you can say something is NULL when it doesn’t have a type and it doesn’t have a value.

And then, you also have ‘undefined’.

So ‘undefined’ basically mean, we know that it is there.

We know that it is there.

Let’s say for instance it’s a variable.

It is there, yes but we don’t, we haven’t given it a value.

It doesn’t have a value.

So NULL is for objects.

We’ll, you’ll see when we start looking at objects.

NULL is for objects whereas ‘undefined’ can be for variables, properties, methods.

So, the primary data types that we have in JavaScript, we have said number, string, boolean, NULL, undefined and symbol.

So symbol, this is new in ECMAScript 2015.

So this is, this one is the data type whereby the instances are unique and immutable.

So you’ll take a look at this, when we get to this part.

So we’ll take a look at this symbols when we get to the part about new things in ECMAScript.

Now, other than the primary data types, we also have objects.

And an object, these are named key value pairs, data containers that you create.

So you can maybe create a ‘person’ object which will store, which will store maybe a name and then on this side.

So an object is a key value pairs of data items that you can create yourself, maybe to store certain kinds of data.

So we’ll look at objects later on.

So in this video, we’ve taken a look at some of the data types that we have in JavaScript and we’ve said that we have the primitive data types which include number, string, boolean, NULL, undefined and symbol.

And then we can also have objects.

So let’s continue in the next video.

Click the button below to watch this full course:

Comment Here

Join this free course:

How to host multiple WordPress
websites on a VPS

Close me!