Primitive Data Types:
The number data type represents both integer and floating-point numbers.
It is used for performing arithmetic operations such as addition, subtraction, multiplication, and division. For example:
var age = 25;
var height = 5.7;
The string data type represents a sequence of characters enclosed in single quotes (”) or double quotes (“”).
Strings are used for storing text values and can be manipulated using various string methods. For example:
var name = “John Doe”;
var message = “Hello, World!”;
The boolean data type has two possible values: true and false.
It is used for logical operations and conditional statements such as if-else statements and while loops. For example:
var isLoggedin = true;
var isValid = false;
The null data type represents the intentional absence of any object value.
It is often used to initialize variables that may be assigned an object later in the program execution. For example:
var car = null;
The undefined data type represents the absence of a defined value.
It is the default value assigned to variables that have been declared but not initialized with a value. For example:
The symbol data type was introduced in ECMAScript 6 and represents a unique identifier.
Symbols are often used as keys for object properties to avoid naming conflicts. For example:
var id = Symbol(“unique-id”);
- The number data type represents numeric values.
- The string data type represents textual values.
- The boolean data type represents true or false values.
- The null data type represents the intentional absence of any object value.
- The undefined data type represents the absence of a defined value.
- The symbol data type represents a unique identifier.
Remember to use appropriate HTML styling elements like for bold text, for underlined text,
- for lists, and
, etc. for subheaders to make your content visually engaging and organized.