Loading, please wait...

A to Z Full Forms and Acronyms

What are JavaScript Data Types ( part 1 )

Sep 03, 2020 JavaScript, 3249 Views
JavaScript Datatypes part 1

JavaScript Data Types part 1

Data types are very important when we do want to understand any functionality for a programming language. It enables to use of JavaScript compatibility with variables so that efficient storage of values are taken into consideration whenever we are doing any programming.

To be able to understand how data is classified in a program is the very initial phase in learning for any programming language. Same in JavaScript, JavaScript variables  can hold many data types as :

  • String
  • Objects 
  • Numbers and more.

In JavaScript it enables the usage of dynamic types i.e, the same variable can be used to hold different data types.

Dynamic types

Example

<!DOCTYPE html>
<html>
<body>

<h2>JavaScript Data Types</h2>

<p>JavaScript has dynamic types.</p>

<p id="TL"></p>

<script>
var A;         //A is undefined
A = 23;         //A is a Number
A = "Rajib";      // A is a String

document.getElementById("TL").innerHTML = A;
</script>

</body>
</html>


JavaScript String

A string is a series of characters or it may be defined as a collection character.

Example

<!DOCTYPE html>
<html>
<body>

<h2>JS Strings</h2>

<p>Strings</p>

<p id="TL"></p>

<script>
var friend1 = "Anil";
var friend2 = 'Rohan';

document.getElementById("TL").innerHTML =
friend1 + "<br>" + 
friend2; 
</script>

</body>
</html>


 

A to Z Full Forms and Acronyms

Related Article