|
| 1 | +--- |
| 2 | +layout: default |
| 3 | +permalink: /logs/2025-12-03/ |
| 4 | +--- |
| 5 | + |
| 6 | +# Devlog - 2025-12-03 |
| 7 | + |
| 8 | +## 🚀 What I Did |
| 9 | + |
| 10 | +- Title case conversion using for loops and maps. |
| 11 | +- Inventory Management. |
| 12 | +- Codewars. |
| 13 | + |
| 14 | +## 🧠 What I Learned |
| 15 | + |
| 16 | +- Boolean - converter function. |
| 17 | +- boolean - data type. |
| 18 | + |
| 19 | +```javascript |
| 20 | +typeof true // "boolean" |
| 21 | +typeof false // "boolean" |
| 22 | + |
| 23 | +Boolean(10) // true |
| 24 | +Boolean(0) // false |
| 25 | +Boolean("hi") // true |
| 26 | +Boolean("") // false |
| 27 | +Boolean(null) // false |
| 28 | +Boolean(true) // true |
| 29 | +``` |
| 30 | + |
| 31 | +### Class |
| 32 | + |
| 33 | +| Use Case | Better Choice | |
| 34 | +| ------------------- | ------------- | |
| 35 | +| Object blueprints | ✅ `class` | |
| 36 | +| Utilities / helpers | ✅ `function` | |
| 37 | +| Modern projects | ✅ `class` | |
| 38 | +| Legacy code | ✅ `function` | |
| 39 | + |
| 40 | +- class is just a blueprint for creating objects. |
| 41 | + |
| 42 | +```javascript |
| 43 | +class Car { |
| 44 | + constructor(name, speed) { |
| 45 | + this.name = name; |
| 46 | + this.speed = speed; |
| 47 | + } |
| 48 | +} |
| 49 | + |
| 50 | +const car1 = new Car("BMW", 120); |
| 51 | +const car2 = new Car("Audi", 150); |
| 52 | +``` |
| 53 | + |
| 54 | +- constructor runs automatically when you create a new object. |
| 55 | +- properties - variables that belong to the object. |
| 56 | +- methods - function inside a class. |
| 57 | +- this - means this current object. |
| 58 | + |
| 59 | +| Use Case | Use Class? | |
| 60 | +| ---------------------- | ---------- | |
| 61 | +| Many similar objects | ✅ | |
| 62 | +| Game characters | ✅ | |
| 63 | +| API models | ✅ | |
| 64 | +| Data structures | ✅ | |
| 65 | +| One small object | ❌ | |
| 66 | +| Simple helper function | ❌ | |
| 67 | + |
| 68 | +- `module` - provides a powerful way to organize and structure js. |
| 69 | + |
| 70 | +```javascript |
| 71 | + |
| 72 | +import anyName from './module.js'; |
| 73 | +``` |
| 74 | + |
| 75 | +## 🔥 What's Next |
| 76 | + |
| 77 | +- mini projects. |
| 78 | +- theory. |
| 79 | + |
| 80 | +--- |
| 81 | + |
| 82 | +[← Previous]({{site.baseurl}}/logs/2025-12-02/) |
0 commit comments