Skip to content

Commit 634eac3

Browse files
feat: update datatypes
added proper datatypes with proper explanation & checked each datatype type using typeof property
1 parent 7c4f3c3 commit 634eac3

File tree

1 file changed

+32
-15
lines changed

1 file changed

+32
-15
lines changed

part1 (Basics)/02_datatypes.js

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
// datatypes.js
2-
31
/*
2+
INFO: DataTypes
43
JavaScript is dynamically typed, so variables can hold any type of data without explicit type declaration.
54
65
Common data types in JavaScript:
@@ -19,7 +18,7 @@ Common data types in JavaScript:
1918

2019
// String
2120
let name = "whoami";
22-
console.log(name); // whoami
21+
console.log(name); // "whoami"
2322

2423
// Number
2524
let score = 102;
@@ -29,22 +28,40 @@ console.log(score); // 102
2928
let isLoggedIn = false;
3029
console.log(isLoggedIn); // false
3130

32-
// Object - Array
31+
// BigInt (used for very large integers beyond Number limit)
32+
let largeNumber = 1234567890123456789012345678901234567890n;
33+
console.log(largeNumber); // 1234567890123456789012345678901234567890n
34+
35+
// Undefined (a variable declared but not assigned a value)
36+
let something;
37+
console.log(something); // undefined
38+
39+
// Null (represents an intentional empty value)
40+
let emptyValue = null;
41+
console.log(emptyValue); // null
42+
43+
// Object – Array
3344
let teaTypes = ["lemon tea", "orange tea", "oolong tea"];
3445
console.log(teaTypes); // ["lemon tea", "orange tea", "oolong tea"]
3546

36-
// Object - Plain Object
37-
let user = { firstName: "whoami", lastName: "dsnake0" };
47+
// Object – Plain Object
48+
let user = {
49+
firstName: "whoami",
50+
lastName: "dsnake0",
51+
};
3852
console.log(user); // { firstName: "whoami", lastName: "dsnake0" }
3953

40-
// Assigning variable values
41-
let getScore = score;
42-
console.log(getScore); // 102
54+
// Symbol (used to create unique identifiers)
55+
let uniqueId = Symbol("id");
56+
console.log(uniqueId); // Symbol(id)
4357

44-
// Undefined example
45-
let something;
46-
console.log(something); // undefined
58+
// INFO: Type of each DataTypes
4759

48-
// Null example
49-
let emptyValue = null;
50-
console.log(emptyValue); // null
60+
console.log(typeof name); // "string"
61+
console.log(typeof score); // "number"
62+
console.log(typeof isLoggedIn); // "boolean"
63+
console.log(typeof largeNumber); // "bigint"
64+
console.log(typeof something); // "undefined"
65+
console.log(typeof emptyValue); // "object" (this is a historical JS bug)
66+
console.log(typeof teaTypes); // "object"
67+
console.log(typeof uniqueId); // "symbol"

0 commit comments

Comments
 (0)