| Viewed 57 times

What are the data types in javascript


What are the data types in javascript

1 Answer
Mikdam Qandeel
Answered
5

In javascript there are many data types, each data type holds different types of values, let's start with the first type which is String, it represents one character or more. eg. "Q" or "Qandeel"

And the second type is Number, which represents a numeric value. eg. (1)  or (079).

Then we have the Boolean, it represents either false or true.

And there are Undefined And Null values we will talk about them later.

Example:

<html>
<body>
<p id="string"></p>
<p id="number"></p>
<p id="boolean"></p>
   <script>

        var a = "I am a text!", //TEXT
         b = 079, //NUMBER
         c = true;  //BOOLEAN

        document.getElementById("string").innerHTML = a;
        document.getElementById("number").innerHTML = b;
        document.getElementById("boolean").innerHTML = c;

    </script>
</body>
</html>

Output:

I am a text!

79

true