Now that you understand objects much better, I have a shocking truth for you. Everything in JavaScript is an object. And what they mean is that literally everything in JavaScript is an object. I'm going to prove it to you so that you understand it even much better. Strings are objects, integers, or numbers are objects, even functions are objects. And I'm going to show you now, for example, suppose that we have a variable called texts.
And it's equal to just the simple texts. For example, this is my text. And if I want to print this on the screen, I would just use console dot log, and I can just pass texts, right and if I see one run, I get the My text, right? And you think now that this is just a simple variable, and that is not true. The truth is that text, this string is an object. Because if you create, if you create a VAR text one, for example, equals to new, and then string, and then you add here, you add the text that you want to print.
Let's copy and paste this inside. And then you pass text one instead of text. If I save and run, I am going to get this is my text. And it's through. It's a string. And as you can see now, strings are objects.
But why would we use this version and not this the other version with the new string that makes it clear that it's an object because the first version which is This one is much easier. Why would we use some something a little bit difficult van just using this. Always go for the easier method, and also integers or numbers or objects. And I'm going to show you that for a H equals 223. Right? This is a simple variable.
If I print it, I'm going to get 23. And we know that but this is actually an object. If I create another variable called age one equals to new and then number and then I pass 23. And then I change this from h1 to from h to h one. And if I say one run, I am going to get 23 and the type is number. So this is a fact this is a fact in JavaScript.
Is that everything in JavaScript is an object. And I'm going to show you also a very interesting thing, which is that you can get the type of a variable using type of function, just type type off. And then you just pass the object or the type or value that we want to get its type. So for example, age one, if I save and run, I am going to get object because it's an object. And for example, text one, I am going to get also that it's an object. And if I use text only text and Save and Run, I am going to get that this is a string.
Now it's more specific, because text because a string is an object, but here it says string. It did not say object because it's now more specific, but it's actually an object. So here, if I Use age only age, I'm gonna get number not an object, but it's actually an object, but it's more specific. So to make things clear, an object is kind of the king. So an object is just kind of the king or the Father, and other values like strings, integers, or numbers, Booleans functions. All of these kind of sons have that King.
So they have the same behavior, so they behave the same. That's why they are objects as well by inheritance.