Exploring the Various Data Types in JavaScript: From Primitives to Objects

Data types in JavaScript describe the different types or kinds of data that you will be working with and storing in variables. It's important that you learn each of these data types because otherwise data can get stored in an improper format which will result in issues in your code later on.n JavaScript, data types are used to classify different types of data and define the type of values that a variable can hold. The main data types in JavaScript include:

Primitive data types: These are the basic data types that include numbers, strings, booleans, and special values like null and undefined.

Data Type Description
String A string is a collection of alphanumeric characters.
Number Numbers are for numbers. We can't put a letter on here.
Boolean Booleans have two values. True and false.
Null and Undefined null and undefined stand for empty. That means they have no value assigned to them.
Symbols Symbol is a primitive data type of JavaScript.It's a very peculiar data type. Once you create a symbol, its value is kept private and for internal use.
Array An array is a type of object used for storing multiple values in single variable.
Object Literals It is a comma-separated list of name-value pairs wrapped in curly braces.
Date JavaScript does not have a date data type. However, you can use the Date object and its methods to work with dates and times in your applications.

JavaScript is a loosely typed language, which means that the data type of a variable does not have to be explicitly declared. Instead, JavaScript automatically determines the data type of a variable based on the value assigned to it. However, it's a good practice to be aware of the data types in JavaScript as you work with variables and write your code.

In addition to these basic data types, JavaScript also has some special data types like Symbol and bigInt, which are used for specific purposes.

Source Code

<!DOCTYPE html>
<html lang="en">
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Tutor Joes</title>
	<script src="js/script.js"></script>
To download raw file Click Here

//Data Types in JavaScript
JS Dynamic Programming
Number   eg:  1.25,25
Boolean  eg:  True,False
Symbols  E6
Object Literals
var a=25.5;
var fname="Tutor Joes";
var isMarried=true;
var phone=null;
let b;
console.log(typeof b);
//ES6 2015
const s1=Symbol() //dlkfngsgs6565df6
const s2=Symbol() //fdfgdfg4345345
var courses=['C','C++','Java'];
var student={
var d=new Date();
console.log(typeof d);
To download raw file Click Here

List of Programs

JS Practical Questions & Answers

JS Practical Project