Skip to content

Commit cd811c8

Browse files
feat: add update primites.js file
1 parent cc05670 commit cd811c8

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Primitive Data Types in JavaScript
2+
// These are the most basic data types — stored directly by value (not by reference).
3+
4+
// 1. Number
5+
let age = 25; // Integer
6+
let pi = 3.14; // Float
7+
8+
console.log(typeof age); // "number"
9+
console.log(typeof pi); // "number"
10+
11+
// 2. String
12+
let name = "Rafay";
13+
let greeting = `Hello, ${name}!`; // Template string (string interpolation)
14+
15+
console.log(typeof name); // "string"
16+
console.log(greeting); // "Hello, Rafay!"
17+
18+
// 3. Boolean
19+
let isOnline = true;
20+
let isAdmin = false;
21+
22+
console.log(typeof isOnline); // "boolean"
23+
24+
// 4. Null
25+
let emptyValue = null;
26+
27+
console.log(typeof emptyValue); // "object" (⚠️ a known JavaScript quirk)
28+
29+
// 5. Undefined
30+
let notAssigned;
31+
32+
console.log(typeof notAssigned); // "undefined"
33+
34+
// 6. BigInt
35+
let bigNumber = 1234567890123456789012345678901234567890n; // Add 'n' at the end
36+
37+
console.log(typeof bigNumber); // "bigint"
38+
39+
// 7. Symbol
40+
let uniqueId1 = Symbol("userId");
41+
let uniqueId2 = Symbol("userId");
42+
43+
console.log(typeof uniqueId1); // "symbol"
44+
console.log(uniqueId1 === uniqueId2); // false – every Symbol is unique!

0 commit comments

Comments
 (0)