top of page

So when something has a truth value. For example, this has a truth value. Evaluate the truth and just look at another different data type which you're going to be exploring a bit later. We have something called a raise. If you have something called my array we use square brackets for that an array is basically values separated by a comma like so. So here we have digital marketing companies in Ahmedabad an array of strings and each string is representing a number. So we can evaluate this entire array. If we do something like this so console log Boullion my array and this will evaluate true because this has truthy values. If we had an empty array like this. Right so we have an array but there's nothing in it. Let's see what that evaluates to.

This still evaluates to true cause if we needed something to be undefined we would have to do it like the way we've seen before us to this will evaluate to false otherwise it has some form it just doesn't have anything inside the array. So just something to be aware of and this can have any kind of stuff you know that could have mixed type of stuff in here for example. And this will still evaluate to true of course because it doesn't really matter digital marketing companies in Ahmedabad what's inside what matters is that it exists. And when I say it kind of Automattic uses this boolean conversion for us that's when javascript is doing some kind of method or function or if statement that is taking in a boolean so it can only take in a boolean and an if statement can only take in a boolean. And again we will explore this in a later video but we can say if my array and what it's doing here is basically doing that. So inside the is saying blue in my array. So what does this statement evaluate to? But we can skip that we can say if my array Ansal log has truthy values else console log has false values. And we social media marketing companies can try out this statement with a couple of our different variables. Let's see what this evaluates to right. This one has truthy values. Therefore this is digital marketing companies in Ahmedabad returns true if it's checking boolean. What is this type of thing? And we already know has content will evaluate to true. If you could check that here and we can check is false. Let's see what happens if we check is false. This one has false values. In fact, this one just has the false value, not false. But if we check for example is.

We know what'll happen or it has false values does not have content. What is this evaluate to of course has falsifiers everything down here will evaluate to false because they have false values. And a final thought. A final note on booleans is that no is not the same thing as undefined. So if we want to check that out we can do something just simple like digital marketing companies in Ahmedabad is no equal to undefined. Let's see what this gives us and it's getting a because they don't have a semi-colon here. So this is false so no and undefined are not the same thing and think of it this way. No is when you deliberately do not assign any kind of value undefined. On the other hand, it just might not currently be defined but it might be expecting a value later on. In other words, it's kind of an uninitialized value. So keep that in mind. These are not the same thing so if you're doing some kind of logic that requires no to be the same is undefined. Well, it's not going to work. Because now it's not the same thing as undefined.

The next javascript type I will be going over it is objects and objects you can think of them as basically collections of name-value pairs. And again if you're coming from another language you are probably used to objects they might have a different name. For example in Ruby they're called hash is in Python they're called dictionaries in C and C plus the called hash tables but they're essentially the same thing. And in practice, as we'll see they basically look like this.

 They're usually wrapped in curly brackets and they have a name-value pair so the name can be something like some kind of key value. For example, you might have something with a key of one and a value of press. For example, if you want digital marketing companies in Ahmedabad to assign this into a variable you like so put some curly brackets at the end and we can cancel log out and see what this looks like in the consul here. What an object looks like. Let's see clear around it again and we can see that evaluates to an object. And it just shows us that. OK here's the key. Associated with this value.

 This is one way as we've just seen to initialize or create an object. There is another way as well. So we could do something like this. We could say for my object the mass space here my object equals new object and we're using the new keyword here. So this is one way and the other way and you know it does look at our warning here it says the object literal notation is preferable which is what we just saw so we could say my other object equals something like this.

So both of these are currently empty objects and they're both pretty much equivalent. And as we just saw in our Linter here object literal notation. That's what this is called. So this is what's known as object literal syntax which we can use digital marketing companies in Ahmedabad just to initialize an object in its entirety if we forget about that for now. If we look at it this way. So the new object method if we want to add key and values in here it's a lot more tedious. And if you want to recreate this object we made just a second ago you would have to do something like my object. And then in brackets here we give it a key to use mean to use the key of one and four key one we can give it equals.

bottom of page