Month End Sale: Get Extra 10% OFF on Job-oriented Training! Offer Ending in
D
H
M
S
Get Now

Data Types and Variables

Level : Beginner
Mentor: Shailendra Chauhan
Duration : 00:00:45

String:

Strings are sequences of characters enclosed in single (' '), double (" "), or backticks (` `) quotes. They are used to represent text data.

Example:

let message = "Hello, World!";
console.log(message); // Output: Hello, World!

Number:

Numbers represent both integers and floating-point values in JavaScript, allowing for mathematical operations.

Example:

let price = 19.99;
console.log(price); // Output: 19.99

BigInt:

BigInt is a special numeric data type in JavaScript that can represent very large integers. It is denoted by appending "n" to the end of a number.

Example:

let bigIntValue = 1234567890123456789012345678901234567890n;
console.log(bigIntValue); // Output: 1234567890123456789012345678901234567890n

Boolean:

Booleans represent true or false values and are often used for conditional statements and logic.

Example:

let isTrue = true;
console.log(isTrue); // Output: true

Undefined:

Undefined represents a variable that has been declared but has not been assigned a value yet.

Example:

let undefinedValue;
console.log(undefinedValue); // Output: undefined

Null:

Null represents the intentional absence of any object value or a variable that has been explicitly set to nothing.

Example:

let emptyValue = null;
console.log(emptyValue); // Output: null

Symbol:

Symbols are unique and immutable data types often used as object property keys to prevent naming conflicts.

Example:

let uniqueSymbol = Symbol("description");
console.log(uniqueSymbol); // Output: Symbol(description) 

Object:

Objects are complex data types that can store key-value pairs and represent structured data.

Example:

let person = {
name: "Alice",
age: 30,
};
console.log(person.name); // Output: Alice

Variables:

Variables are containers that store data values, enabling you to manage and manipulate information throughout your code. They contribute to code organization, reusability, and dynamic behavior.

Example:

let age = 25; 

Declaring Variables:

Declaring variables is the initial step in utilizing them. It involves announcing the variable's name, which becomes a reference point for the associated data.

Example:

let message;
message = "Hello, developers!";
console.log(message);

let Keyword:

The 'let' keyword enables the creation of variables that can be reassigned. Its block scope confines the variable's accessibility to the code block in which it's defined.

Example:

let count = 3;
count = 5;  // Reassigning the value
console.log(count);  // Outputs: 5

const Keyword:

The 'const' keyword is used to declare variables with constant values that cannot be changed after assignment. It promotes data integrity and protects against unintended modifications.

Example:

const PI = 3.14159;
console.log(PI);  // Outputs: 3.14159 

Undefined:

Variables declared without an initial value are assigned the value 'undefined'. It signifies the absence of a meaningful value and is often used to identify uninitialized variables.

Example:

let undefinedValue;
console.log(undefinedValue);  // Outputs: undefined 

Self-paced Membership
  • 22+ Video Courses
  • 800+ Hands-On Labs
  • 400+ Quick Notes
  • 55+ Skill Tests
  • 45+ Interview Q&A Courses
  • 10+ Real-world Projects
  • Career Coaching Sessions
  • Email Support
Upto 60% OFF
Know More
Still have some questions? Let's discuss.
CONTACT US
Accept cookies & close this