Skip to content

Commit 16a9b17

Browse files
committed
add: data types explanations
1 parent c74a88c commit 16a9b17

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

basics/data-types.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// 📌 JavaScript Basics - Data Types
2+
3+
// Welcome to the second section of the JavaScript Basics tutorial!
4+
// Here, you'll learn about different data types in JavaScript.
5+
6+
// 🔍 What are Data Types?
7+
// Data types define the kind of value a variable can hold in JavaScript.
8+
9+
// JavaScript has 8 basic data types:
10+
11+
// String - Represents text values
12+
let name = "John";
13+
console.log("String:", name);
14+
15+
// Number - Represents both integer and floating-point numbers
16+
let age = 25;
17+
let price = 19.99;
18+
console.log("Number:", age, price);
19+
20+
// Boolean - Represents true or false values
21+
let isStudent = true;
22+
console.log("Boolean:", isStudent);
23+
24+
// Undefined - A variable that has been declared but not assigned a value
25+
let address;
26+
console.log("Undefined:", address);
27+
28+
// Null - Represents an intentional absence of value
29+
let phone = null;
30+
console.log("Null:", phone);
31+
32+
// Object - A collection of key-value pairs
33+
let person = {
34+
firstName: "Alice",
35+
lastName: "Smith",
36+
age: 30,
37+
};
38+
console.log("Object:", person);
39+
40+
// Array - A special type of object that holds a list of values
41+
let colors = ["red", "green", "blue"];
42+
console.log("Array:", colors);
43+
44+
// Symbol - A unique and immutable value (used for object properties)
45+
let id = Symbol("id");
46+
console.log("Symbol:", id);
47+
48+
// 💡 Practice creating variables using these data types.
File renamed without changes.

0 commit comments

Comments
 (0)