moving
Some checks failed
Installer Smoke / installer-smoke (push) Has been cancelled

This commit is contained in:
Oleg Maslov
2026-09-02 10:10:29 +02:00
commit 0c3e2ead3b
3841 changed files with 970576 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
{
"baseline": "You are a coding assistant. Answer the user's coding question clearly.",
"evolved": "You are a coding assistant. Answer the user's coding question with precision and appropriate brevity. Lead with the core insight or direct answer first, then provide supporting details only if necessary. For questions asking for \"the key difference\" or \"the main reason,\" prioritize a concise explanation (1-3 sentences) over comprehensive breakdowns. Include a brief example only when it clarifies ambiguity. Avoid verbose elaboration unless the question explicitly requests depth or a comprehensive guide.",
"delta": 0.02833333333333332,
"winnerId": "g1-m0",
"winnerScore": {
"overall": 0.9049999999999999,
"correctness": 0.9100000000000001,
"procedureFollowing": 1,
"conciseness": 0.7499999999999999,
"lengthPenalty": 1,
"n": 10,
"weaknessFeedback": [
"The response is largely correct and well-structured with a helpful example. However, it emphasizes the dangling pointer risk slightly more than the core issue—the actual problem is ambiguity about which input a reference borrows from, not just safety guarantees. Consider leading with the ambiguity point to align more closely with the expected explanation.",
"The response is factually sound and well-structured, but includes extra detail (C-extensions, asyncio) beyond the expected answer's scope. Consider whether the instruction asks for comprehensive coverage or a concise explanation—if conciseness is valued, trim to the core three points (I/O threading, multiprocessing, and the parallelism vs. concurrency distinction).",
"The response is accurate and well-structured with helpful examples. To improve conciseness, consider consolidating the 'Key distinctions' section into the main paragraph rather than using a separate bulleted list, as the information is somewhat redundant with the opening statement."
]
},
"historyCount": 7
}

View File

@@ -0,0 +1,42 @@
[
{
"id": "js-map-vs-foreach",
"output": "# `Array.prototype.map` vs `Array.prototype.forEach`\n\n## The Key Difference\n\n**`map` returns a new array** with the results of calling a function on every element, while **`forEach` returns `undefined`** and simply executes a function for each element (side effects only).\n\n---\n\n## `forEach` — Used for **side effects**\n\n```javascript\nconst numbers = [1, 2, 3];\n\nconst result = numbers.forEach(num => {\n console.log(num * 2); // prints 2, 4, 6\n});\n\nconsole.log(result); // undefined\n```\n\n## `map` — Used for **transformations**\n\n```javascript\nconst numbers = [1, 2, 3];\n\nconst result = numbers.map(num => num * 2);\n\nconsole.log(result); // [2, 4, 6]\n```\n\n---\n\n## Summary Table\n\n| Feature | `map()` | `forEach()` |\n|--------------------|--------------------------------|------------------------------|\n| **Return value** | New array | `undefined` |\n| **Purpose** | Transform data | Perform side effects |\n| **Chainable?** | ✅ Yes (returns an array) | ❌ No (returns `undefined`) |\n| **Mutates original?** | No (unless you explicitly do) | No (unless you explicitly do) |\n\n---\n\n## When to Use Which?\n\n- **Use `map`** when you need a **new array** based on transforming each element:\n ```javascript\n const names = users.map(user => user.name); // extract names\n ```\n\n- **Use `forEach`** when you just want to **do something** with each element (e.g., logging, updating the DOM, pushing to an external array):\n ```javascript\n users.forEach(user => sendEmail(user)); // side effect\n ```\n\n> **Rule of thumb:** If you're not using the returned array from `map`, you should probably be using `forEach` instead. Conversely, if you're building a new array inside `forEach`, you should probably be using `map`."
},
{
"id": "py-list-tuple",
"output": "# Tuples vs Lists in Python\n\n## Use a **Tuple** When:\n\n### 1. **Data is immutable (shouldn't change)**\nTuples signal that the data is fixed and read-only.\n```python\n# Coordinates, RGB colors, database records\npoint = (3, 5)\ncolor = (255, 128, 0)\n```\n\n### 2. **Heterogeneous, structured data (like a record)**\nWhen each position has a specific meaning:\n```python\n# (name, age, city) — like a lightweight struct\nperson = (\"Alice\", 30, \"New York\")\n```\n\n### 3. **Dictionary keys or set elements**\nTuples are **hashable** (if their contents are); lists are not:\n```python\n# ✅ Works\nlocations = {(40.7, -74.0): \"New York\", (34.0, -118.2): \"LA\"}\n\n# ❌ TypeError: unhashable type: 'list'\nlocations = {[40.7, -74.0]: \"New York\"}\n```\n\n### 4. **Performance matters**\nTuples are slightly faster and use less memory:\n```python\nimport sys\nprint(sys.getsizeof((1, 2, 3))) # 64 bytes (typical)\nprint(sys.getsizeof([1, 2, 3])) # 88 bytes (typical)\n```\n\n### 5. **Returning multiple values from a function**\n```python\ndef get_dimensions():\n return (1920, 1080) # parentheses optional\n\nwidth, height = get_dimensions()\n```\n\n---\n\n## Use a **List** When:\n\n### 1. **Data needs to be modified**\n```python\nshopping = [\"milk\", \"eggs\"]\nshopping.append(\"bread\") # Lists support mutation\nshopping.remove(\"milk\")\n```\n\n### 2. **Homogeneous collection (same type of items)**\nWhen you have a sequence of similar things:\n```python\nscores = [95, 87, 92, 78]\nnames = [\"Alice\", \"Bob\", \"Charlie\"]\n```\n\n### 3. **You need to sort, filter, or iterate and modify**\n```python\nnumbers = [3, 1, 4, 1, 5]\nnumbers.sort()\n```\n\n---\n\n## Quick Reference\n\n| Criteria | Tuple | List |\n|---|---|---|\n| **Mutable?** | ❌ No | ✅ Yes |\n| **Hashable?** | "
},
{
"id": "sql-inner-vs-left",
"output": "# INNER JOIN vs LEFT JOIN in SQL\n\n## INNER JOIN\n\nAn **INNER JOIN** returns only the rows where there is a **match in both tables**.\n\n```sql\nSELECT employees.name, departments.dept_name\nFROM employees\nINNER JOIN departments ON employees.dept_id = departments.id;\n```\n\n### Visualization:\n```\nTable A Table B\n┌─────┐ ┌─────┐\n│ │ │ │\n│ ┌──┼───────┼──┐ │\n│ │ │ RESULT│ │ │ ← Only the overlap\n│ └──┼───────┼──┘ │\n│ │ │ │\n└─────┘ └─────┘\n```\n\n---\n\n## LEFT JOIN (LEFT OUTER JOIN)\n\nA **LEFT JOIN** returns **all rows from the left table**, and the matched rows from the right table. If there's **no match**, the right side will contain `NULL`.\n\n```sql\nSELECT employees.name, departments.dept_name\nFROM employees\nLEFT JOIN departments ON employees.dept_id = departments.id;\n```\n\n### Visualization:\n```\nTable A Table B\n┌─────┐ ┌─────┐\n│█████│ │ │\n│█████│───────┼──┐ │ ← All of Table A + matching from B\n│█████│ RESULT│ │ │\n│█████│───────┼──┘ │\n│█████│ │ │\n└─────┘ └─────┘\n```\n\n---\n\n## Practical Example\n\nGiven these tables:\n\n| **employees** | | **departments** | |\n|---|---|---|---|\n| name | dept_id | id | dept_name |\n| Alice | 1 | 1 | Engineering |\n| Bob | 2 | 2 | Marketing |\n| Carol | **NULL** | 3 | Sales |\n\n### INNER JOIN Result:\n| name | dept_name |\n|-------|-------------|\n| Alice | Engineering |\n| Bob | Marketing |\n\n> ❌ Carol is **excluded** (no matching dept_id)\n> ❌ Sales is **excluded** (no employee references it)\n\n### LEFT JOIN Result:\n| name | dept_name |\n|-------|-------------|\n| Alice | Engineering |\n| Bob | Marketing |\n| Carol | **NULL** |\n\n> ✅ Carol is **included** with NULL for dept_name\n> ❌ Sales is still excluded"
},
{
"id": "ts-type-vs-interface",
"output": "# TypeScript: Type Alias vs Interface\n\nBoth `type` and `interface` can describe object shapes, but they have key differences that guide when to use each.\n\n## Interface\n\nBest for **defining object shapes and contracts**, especially when you expect them to be extended or implemented.\n\n```typescript\ninterface User {\n name: string;\n age: number;\n}\n\n// ✅ Declaration merging (auto-extends across files)\ninterface User {\n email: string;\n}\n\n// ✅ Extends other interfaces\ninterface Admin extends User {\n role: string;\n}\n\n// ✅ Classes can implement them\nclass AppUser implements User {\n name = \"John\";\n age = 30;\n email = \"john@example.com\";\n}\n```\n\n## Type Alias\n\nBest for **unions, intersections, tuples, primitives, and complex type expressions**.\n\n```typescript\n// ✅ Union types (interfaces CAN'T do this)\ntype Status = \"active\" | \"inactive\" | \"banned\";\ntype Result = Success | Error;\n\n// ✅ Intersection types\ntype Admin = User & { role: string };\n\n// ✅ Tuples\ntype Coordinate = [number, number];\n\n// ✅ Mapped / conditional types\ntype Readonly<T> = { readonly [K in keyof T]: T[K] };\ntype Nullable<T> = T | null;\n\n// ✅ Primitives & utility aliases\ntype ID = string | number;\n```\n\n## Quick Decision Guide\n\n| Scenario | Use |\n|---|---|\n| Object shape / API contract | `interface` |\n| Union or intersection types | `type` |\n| Declaration merging needed (e.g., library augmentation) | `interface` |\n| Tuples | `type` |\n| Primitives / literal types | `type` |\n| Mapped / conditional types | `type` |\n| Class implementation contract | `interface` |\n| Function signatures (standalone) | Either (both work) |\n\n## Key Differences Summary\n\n```typescript\n// 1. Declaration merging — only interface\ninterface Window {\n myCustomProp: string; // merges with global Window\n}\n\n// 2. Union — only type\ntype Input = string | number; // interface can't do this\n\n// 3. Computed properties — only type\ntype Keys = \"x\" | \"y\";\ntype Point = { [K in Keys]: number }; // { x: number; y: number }\n```\n\n## Rule of Thumb\n\n> - Use **`interface`** for public APIs,"
},
{
"id": "regex-bug",
"output": "# The Problem with `/^[a-z]+$/` and Non-ASCII Lowercase Letters\n\n## The Issue\n\nThe regex `/^[a-z]+$/` **only matches ASCII lowercase letters** (a through z). It will **fail** to match non-ASCII lowercase letters like `é`, `ñ`, `ü`, `ø`, etc.\n\n```javascript\nconst regex = /^[a-z]+$/;\n\nconsole.log(regex.test('hello')); // ✅ true\nconsole.log(regex.test('café')); // ❌ false (because of 'é')\nconsole.log(regex.test('naïve')); // ❌ false (because of 'ï')\n```\n\n## Why?\n\nThe character class `[a-z]` is a **range based on character codes** (97122 in Unicode/ASCII). It only covers the 26 basic Latin lowercase letters. Characters like `é` (U+00E9) fall outside this range.\n\n## Solutions\n\n### 1. Use Unicode Property Escapes (Recommended, Modern JS)\n\n```javascript\nconst regex = /^\\p{Lowercase_Letter}+$/u;\n\nconsole.log(regex.test('hello')); // ✅ true\nconsole.log(regex.test('café')); // ✅ true\nconsole.log(regex.test('naïve')); // ✅ true\nconsole.log(regex.test('Hello')); // ❌ false\n```\n\n> The `u` flag enables Unicode mode, and `\\p{Lowercase_Letter}` matches **any** Unicode lowercase letter.\n\n### 2. Alternative Unicode Property Shorthand\n\n```javascript\nconst regex = /^\\p{Ll}+$/u; // 'Ll' = \"Letter, lowercase\"\n\nconsole.log(regex.test('café')); // ✅ true\nconsole.log(regex.test('über')); // ✅ true\n```\n\n### 3. Case-Insensitive Workaround (Less Precise)\n\n```javascript\nconst regex = /^\\p{Letter}+$/u;\n\n// Then check if the string equals its lowercase form\nfunction isAllLowercase(str) {\n return /^\\p{Letter}+$/u.test(str) && str === str.toLowerCase();\n}\n```\n\n## Key Takeaway\n\n| Regex | Matches `é`? | Matches `ñ`? | Unicode-aware? |\n|-------|:-----------:|:-----------:|:--------------:|\n| `/^[a-z]+$/"
},
{
"id": "async-race",
"output": "# Sequential `await` vs `Promise.all`\n\nThe key difference is **concurrency** — how the promises execute in relation to each other.\n\n## Sequential `await`\n\n```javascript\nasync function sequential() {\n const a = await fetchUser(); // Starts and waits (e.g., 2s)\n const b = await fetchOrders(); // Starts AFTER a finishes (e.g., 2s)\n // Total time: ~4s\n}\n```\n\n- The second promise **doesn't start until the first resolves**\n- Total time = sum of both durations\n\n## `Promise.all`\n\n```javascript\nasync function parallel() {\n const [a, b] = await Promise.all([\n fetchUser(), // Starts immediately (e.g., 2s)\n fetchOrders() // Starts immediately (e.g., 2s)\n ]);\n // Total time: ~2s\n}\n```\n\n- Both promises start **at the same time**\n- Total time = duration of the **slowest** one\n\n## Visual Timeline\n\n```\nSequential:\n fetchUser: |████████|\n fetchOrders: |████████|\n Total: |================| ~4s\n\nPromise.all:\n fetchUser: |████████|\n fetchOrders: |████████|\n Total: |========| ~2s\n```\n\n## Error Handling Differences\n\n| Behavior | Sequential `await` | `Promise.all` |\n|---|---|---|\n| **First fails** | Stops immediately, second never runs | Both were started; rejects with first error |\n| **Second fails** | Only happens if first succeeded | Rejects as soon as *any* promise rejects |\n| **Both fail** | Only first error is thrown | First rejection is thrown; second is potentially an unhandled rejection |\n\n```javascript\n// Promise.all — fails fast\ntry {\n const [a, b] = await Promise.all([slow(), fast()]);\n} catch (e) {\n // If fast() rejects first, you get that error immediately\n // slow() is still running but its result is ignored\n}\n```\n\n## When to Use Which\n\n- **`Promise.all`** — when the promises are **independent** (e.g., fetching unrelated data)\n- **Sequential** — when the second depends on the first's result:\n\n```javascript\nconst user = await fetchUser(id);\nconst orders = await fetchOrders(user.accountId); // needs user first\n```\n\n## Bonus: `Promise.allSettled`"
},
{
"id": "go-slice-append",
"output": "# Why `append` Can Unexpectedly Modify Other Slices in Go\n\nThis is one of Go's most common gotchas, and it stems from how slices work internally.\n\n## Slice Internals\n\nA slice is a **three-field struct** (a \"slice header\"):\n\n```go\ntype slice struct {\n array unsafe.Pointer // pointer to underlying array\n len int\n cap int\n}\n```\n\nWhen you create a sub-slice, the new slice **shares the same underlying array**:\n\n```go\noriginal := make([]int, 5, 10) // len=5, cap=10\nsub := original[1:3] // len=2, cap=9 — same backing array!\n```\n\n## The Problem\n\n`append` has two behaviors depending on capacity:\n\n1. **If `len < cap`**: writes into the existing array (no allocation)\n2. **If `len == cap`**: allocates a new, larger array (safe)\n\n**Case 1 is where the bug hides:**\n\n```go\na := make([]int, 3, 5) // [0, 0, 0], cap=5\na[0], a[1], a[2] = 1, 2, 3\n\nb := a[:2] // [1, 2], cap=5 — shares same array\n\n// b has len=2, cap=5, so there's room — no new allocation!\nb = append(b, 99)\n\nfmt.Println(b) // [1 2 99]\nfmt.Println(a) // [1 2 99] ← a[2] was silently overwritten!\n```\n\n### What happened:\n\n```\nUnderlying array: [1, 2, 3, 0, 0]\n ^\n append wrote 99 here (index 2)\n \nBoth 'a' and 'b' point to this same array,\nso a[2] changed from 3 to 99.\n```\n\n## A More Realistic Example\n\nThis commonly occurs when building results from a shared prefix:\n\n```go\npath := []string{\"home\", \"user\"}\n\n// Two different paths branching from the same prefix\npathA := append(path, \"documents\")\npathB := append(path, \"pictures\") // Overwrites \"documents\"!\n\nfmt.Println(pathA) // [home user pictures] ← WRONG!\nfmt.Println(pathB) // [home user pictures]\n```\n\nBoth `append` calls wrote to `path["
},
{
"id": "rust-lifetime",
"output": "# Why Rust Requires Explicit Lifetimes on Returned References\n\nWhen a function returns a reference, the compiler needs to know **how long that reference is valid**. Without a lifetime annotation, the compiler can't determine which input the returned reference is tied to, making it impossible to guarantee memory safety.\n\n## The Problem\n\n```rust\n// ❌ This won't compile\nfn longest(x: &str, y: &str) -> &str {\n if x.len() > y.len() { x } else { y }\n}\n```\n\nThe compiler asks: *\"Does the returned reference live as long as `x`, as long as `y`, or something else?\"* It can't figure this out on its own because the choice depends on **runtime logic**.\n\n## The Fix\n\n```rust\n// ✅ Explicit lifetime tells the compiler the relationship\nfn longest<'a>(x: &'a str, y: &'a str) -> &'a str {\n if x.len() > y.len() { x } else { y }\n}\n```\n\nThis says: \"The returned reference will be valid for at least as long as **both** `x` and `y` are valid\" (i.e., `'a` is the shorter of the two lifetimes).\n\n## Why the Compiler Can't Just Guess\n\nThe compiler analyzes functions **independently** — it doesn't look at how a function is called to determine lifetimes. It needs the signature alone to enforce safety at every call site:\n\n```rust\nfn main() {\n let string1 = String::from(\"hello\");\n let result;\n {\n let string2 = String::from(\"world\");\n result = longest(&string1, &string2);\n }\n // ❌ Compiler catches this: string2 is dropped, but result might point to it\n println!(\"{}\", result);\n}\n```\n\nWithout the lifetime annotation, the compiler couldn't reject this code.\n\n## When You *Don't* Need Explicit Lifetimes\n\nRust has **lifetime elision rules** that let you omit lifetimes in unambiguous cases:\n\n```rust\n// ✅ Only one input reference, so the output obviously borrows from it\nfn first_word(s: &str) -> &str {\n // compiler infers: fn first_word<'a>(s: &'a str) -> &'a str\n &s[..s.find(' ').unwrap_or(s.len())]\n}\n\n// ✅ &self methods — output lifetime is assumed to match &self\nimpl MyStruct {"
},
{
"id": "python-gil",
"output": "# The Python GIL and Concurrency\n\n**No, the GIL does not prevent all concurrency.** It's a common misconception. Here's the nuanced picture:\n\n## What the GIL Does\n\nThe **Global Interpreter Lock** (in CPython) ensures that only **one thread executes Python bytecode at a time**. This limits **CPU-bound parallelism** with threads.\n\n```python\n# CPU-bound work — GIL limits this to ~1 core with threads\nimport threading\n\ndef count():\n total = 0\n for _ in range(10_000_000):\n total += 1\n\n# These run essentially sequentially due to the GIL\nt1 = threading.Thread(target=count)\nt2 = threading.Thread(target=count)\n```\n\n## What the GIL Does NOT Prevent\n\n### 1. **I/O-bound concurrency with threads** ✅\nThe GIL is **released during I/O operations** (network, disk, sleep):\n\n```python\nimport threading, requests\n\n# These actually run concurrently — GIL is released during I/O\nurls = [\"https://example.com\"] * 10\nthreads = [threading.Thread(target=requests.get, args=(url,)) for url in urls]\n```\n\n### 2. **Multiprocessing** ✅\nEach process has its **own GIL**, so true parallelism is possible:\n\n```python\nfrom multiprocessing import Pool\n\ndef cpu_heavy(n):\n return sum(range(n))\n\nwith Pool(4) as p:\n results = p.map(cpu_heavy, [10**7] * 4) # Uses 4 cores\n```\n\n### 3. **Async I/O** ✅\nCooperative concurrency within a single thread:\n\n```python\nimport asyncio, aiohttp\n\nasync def fetch(session, url):\n async with session.get(url) as resp:\n return await resp.text()\n\nasync def main():\n async with aiohttp.ClientSession() as session:\n tasks = [fetch(session, \"https://example.com\") for _ in range(10)]\n await asyncio.gather(*tasks) # Concurrent I/O\n```\n\n### 4. **C extensions that release the GIL** ✅\nLibraries like **NumPy**, **pandas**, and **scikit-learn** release the GIL during heavy computation:\n\n```python\nimport numpy as np\nfrom threading import Thread\n\n# NumPy releases the GIL — true parallel execution"
},
{
"id": "react-key",
"output": "# Why React Requires Unique `key` Props in Lists\n\n## The Short Answer\n\nReact uses `key` props to **identify which items in a list have changed, been added, or been removed**. Keys help React's **reconciliation algorithm** (diffing) efficiently update the DOM.\n\n## The Problem Without Keys\n\nWhen React re-renders a list, it needs to match elements between the old and new virtual DOM trees. Without keys, React compares elements **by index position**:\n\n```jsx\n// ❌ Without keys — React uses index by default\n// Before:\n<ul>\n <li>Apple</li>\n <li>Banana</li>\n</ul>\n\n// After (inserting \"Cherry\" at the top):\n<ul>\n <li>Cherry</li> // React thinks \"Apple\" mutated into \"Cherry\"\n <li>Apple</li> // React thinks \"Banana\" mutated into \"Apple\"\n <li>Banana</li> // React sees a new element — creates it\n</ul>\n```\n\nReact ends up **re-rendering every item** instead of just inserting one — this is inefficient and can cause **bugs with component state**.\n\n## How Keys Fix This\n\n```jsx\n// ✅ With keys — React tracks each item by identity\n// Before:\n<ul>\n <li key=\"apple\">Apple</li>\n <li key=\"banana\">Banana</li>\n</ul>\n\n// After:\n<ul>\n <li key=\"cherry\">Cherry</li> // React knows this is NEW\n <li key=\"apple\">Apple</li> // React knows this MOVED\n <li key=\"banana\">Banana</li> // React knows this MOVED\n</ul>\n```\n\nReact now correctly **inserts** one element and **moves** the others — no unnecessary re-renders.\n\n## Key Rules\n\n| ✅ Do | ❌ Don't |\n|-------|----------|\n| Use stable, unique IDs (`item.id`) | Use array index as key (if list reorders) |\n| Keep keys consistent across renders | Use `Math.random()` or `Date.now()` |\n| Keys must be unique among **siblings** | Keys don't need to be globally unique |\n\n## Common Example\n\n```jsx\nconst TodoList = ({ todos }) => (\n <ul>\n {todos.map((todo) => (\n // ✅ Use a stable unique identifier\n <li key={todo.id}>{todo.text}</li>\n ))}\n </ul>\n);\n```\n\n## When Index"
}
]

View File

@@ -0,0 +1,42 @@
[
{
"id": "js-map-vs-foreach",
"output": ""
},
{
"id": "py-list-tuple",
"output": "In Python, the fundamental difference between a list and a tuple is **mutability**. A list is mutable (you can change, add, or remove elements), while a tuple is immutable (once created, it cannot be changed).\n\nHere are the specific scenarios when you should choose a tuple over a list:\n\n### 1. When the data should not change (Data Integrity)\nIf you have a collection of values that should remain constant throughout the lifecycle of your program, use a tuple. This prevents accidental modification (bugs) by other parts of your code.\n* **Example:** Days of the week, RGB color codes, or configuration settings.\n ```python\n # A list could be accidentally changed\n days_of_week = (\"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\", \"Saturday\", \"Sunday\")\n ```\n\n### 2. When using the collection as a Dictionary Key\nIn Python, only **hashable** objects can be used as keys in a dictionary or elements in a set. Because lists are mutable, they are not hashable. Tuples, being immutable, are hashable.\n* **Example:** Using geographic coordinates as a key.\n ```python\n # This works\n locations = {\n (40.7128, -74.0060): \"New York\",\n (34.0522, -118.2437): \"Los Angeles\"\n }\n\n # This would raise a TypeError: unhashable type: 'list'\n # locations = {[40.7128, -74.0060]: \"New York\"} \n ```\n\n### 3. For \"Heterogeneous\" Data (Structuring Records)\nBy convention, **lists** are used for *homogeneous* data (a list of the same type of things, like a list of usernames). **Tuples** are often used for *heterogeneous* data (different types of data that belong together as a single record).\n* **Example:** A database record.\n ```python\n # (Name, Age, Job) -> Different types of data forming one \"object\"\n user_record = (\"Alice\", 30, \"Engineer\") \n ```\n\n### 4. For Performance (Slight Optimization)\nBecause tuples are immutable, Python allocates a fixed block of memory for them. Lists, however, require extra memory to allow for potential growth (over-allocation).\n* **Speed:** Iterating over a tuple is slightly faster than iterating over a list.\n* **Memory:** Tuples occupy slightly less space in RAM.\n* *Note: This only matters if you are dealing with millions of elements or extremely tight performance constraints.*\n\n### 5. For Function Return Values"
},
{
"id": "sql-inner-vs-left",
"output": "The simplest way to understand the difference between an `INNER JOIN` and a `LEFT JOIN` is by looking at how they handle **unmatched data**.\n\nHere is the clear breakdown.\n\n---\n\n### 1. INNER JOIN\nAn `INNER JOIN` returns only the rows where there is a **match in both tables**. If a row in Table A does not have a corresponding match in Table B, that row is excluded from the results entirely.\n\n* **Think of it as:** An \"Intersection\" (like a Venn diagram).\n* **Use case:** When you only want records that are complete and have related data in both tables.\n\n**Example:**\nImagine a `Customers` table and an `Orders` table.\n* **Customer A** has placed 2 orders.\n* **Customer B** has placed 0 orders.\n\nAn `INNER JOIN` will return **Customer A** (because they have orders), but **Customer B will be completely hidden** from the results.\n\n---\n\n### 2. LEFT JOIN (or LEFT OUTER JOIN)\nA `LEFT JOIN` returns **all rows from the left table**, regardless of whether there is a match in the right table. If no match is found, the result will contain `NULL` values for all columns of the right table.\n\n* **Think of it as:** \"Everything from the left, and only the matches from the right.\"\n* **Use case:** When you want a complete list of items from one table, even if they don't have associated data in the second table.\n\n**Example:**\nUsing the same `Customers` and `Orders` tables:\n* **Customer A** has placed 2 orders.\n* **Customer B** has placed 0 orders.\n\nA `LEFT JOIN` will return **Customer A** (with their order details) AND **Customer B**. For Customer B, the order columns (like `OrderDate` or `OrderID`) will simply say `NULL`.\n\n---\n\n### Summary Comparison Table\n\n| Feature | INNER JOIN | LEFT JOIN |\n| :--- | :--- | :--- |\n| **Result Set** | Only matching rows from both tables. | All rows from left table + matches from right. |\n| **Unmatched Left Rows** | Discarded. | Kept (Right side filled with `NULL`). |\n| **Unmatched Right Rows** | Discarded. | Discarded. |\n| **Venn Diagram** | The overlapping middle section. | The entire left circle (including the middle). |\n\n### Quick Code Example\n\n```sql\n-- INNER JOIN: Only get customers who have actually placed orders\nSELECT Customers.Name, Orders.OrderID\nFROM Customers\nINNER JOIN Orders ON Customers.CustomerID = Orders.CustomerID;\n\n-- LEFT JOIN: Get ALL customers, and show their orders if"
},
{
"id": "ts-type-vs-interface",
"output": "In modern TypeScript, `type` and `interface` are more similar than they are different. For most day-to-day object definitions, you can use either. However, there are specific technical reasons to choose one over the other.\n\nHere is the breakdown of when to use which.\n\n---\n\n### 1. Use `interface` when...\n\n**You are defining the \"shape\" of an object or a class.**\nInterfaces are designed specifically for object-oriented structures. If you are defining a blueprint for a data object, a component's props, or a class implementation, use an interface.\n\n**You need \"Declaration Merging.\"**\nThis is the most significant technical difference. If you define two interfaces with the same name in the same scope, TypeScript automatically merges them into one. This is essential for extending third-party libraries.\n\n```typescript\ninterface User {\n name: string;\n}\n\ninterface User {\n age: number;\n}\n\n// Result: User has both name and age\nconst person: User = { name: \"Alice\", age: 30 };\n```\n\n**You are building a library/API for others.**\nBecause of declaration merging, users of your library can add properties to your interfaces to suit their needs without modifying your source code.\n\n---\n\n### 2. Use `type` when...\n\n**You need a Union or Intersection type.**\nInterfaces cannot be unions. If a value can be \"this OR that,\" you must use a type alias.\n\n```typescript\ntype Status = \"success\" | \"error\" | \"loading\";\ntype ID = string | number;\n```\n\n**You are defining Primitives, Tuples, or Functions.**\nWhile interfaces can describe functions, `type` is much more concise for simple aliases.\n\n```typescript\ntype Point = [number, number]; // Tuple\ntype Callback = (data: string) => void; // Function\ntype Name = string; // Primitive alias\n```\n\n**You need Advanced Type Mapping.**\nIf you are using mapped types, conditional types, or utility types (like `Pick`, `Omit`, or `Partial`), you must use `type`.\n\n```typescript\ntype User = { id: number; name: string; email: string };\ntype UserPreview = Pick<User, \"id\" | \"name\">; // Only possible with 'type'\n```\n\n---\n\n### Summary Comparison Table\n\n| Feature | Interface | Type Alias |\n| :--- | :--- | :--- |\n| **Object shapes** | ✅ Yes | ✅ Yes |\n| **Union types** | ❌ No | ✅ Yes |\n| **Primitive aliases** | ❌ No | ✅ Yes |\n| **Declaration Merging** | ✅ Yes | ❌ No |\n| **Extensibility** | `extends` keyword | `&`"
},
{
"id": "regex-bug",
"output": "The issue is that the character range `[a-z]` in JavaScript regular expressions is **strictly limited to the ASCII character set** (the English alphabet).\n\n### Why it fails\nIn the ASCII table, `a` is character code 97 and `z` is 122. The regex `/^[a-z]+$/` tells the engine: *\"Match only characters with codes between 97 and 122.\"*\n\nCharacters like **`é`**, **`ö`**, **`ñ`**, or **`ç`** have character codes far outside that range (e.g., `é` is code 233). Therefore, the regex treats them as \"non-matching\" characters, and the validation fails.\n\n---\n\n### The Solution: Unicode Property Escapes\nTo support lowercase letters from all languages (including accented characters), you should use **Unicode Property Escapes**. \n\nYou can use `\\p{Ll}`, which stands for **L**etter, **l**owercase.\n\n#### Corrected Code:\n```javascript\n// Note the 'u' flag at the end; it is REQUIRED for Unicode properties\nconst regex = /^\\p{Ll}+$/u; \n\nconsole.log(regex.test(\"hello\")); // true\nconsole.log(regex.test(\"é\")); // true\nconsole.log(regex.test(\"Héllö\")); // false (contains uppercase 'H')\nconsole.log(regex.test(\"123\")); // false\n```\n\n### Key Requirements for this to work:\n1. **The `u` flag:** You must append the `u` (Unicode) flag to the end of the regex (`/ ... /u`). Without this flag, `\\p{...}` will be treated as a literal \"p\" and will not work.\n2. **Environment:** Unicode property escapes are supported in all modern browsers and Node.js (v10+).\n\n### Summary Comparison\n| Regex | Matches `a` | Matches `é` | Matches `A` | Logic |\n| :--- | :---: | :---: | :---: | :--- |\n| `/^[a-z]+$/` | ✅ | ❌ | ❌ | ASCII only (English) |\n| `/^\\p{Ll}+$/u` | ✅ | ✅ | ❌ | Any Unicode lowercase letter |"
},
{
"id": "async-race",
"output": "The primary difference between awaiting promises sequentially and using `Promise.all` is **concurrency**. \n\nSequential awaiting executes tasks one after another (blocking), while `Promise.all` allows them to run simultaneously (non-blocking).\n\nHere is the detailed breakdown.\n\n---\n\n### 1. Sequential Awaiting (Series)\nWhen you `await` each promise on a new line, the JavaScript engine pauses the execution of that `async` function until the current promise resolves before moving to the next line.\n\n```javascript\nasync function sequential() {\n const user = await fetchUser(); // Takes 1 second\n const posts = await fetchPosts(); // Takes 1 second\n return { user, posts };\n}\n// Total time: ~2 seconds\n```\n\n**What happens here:**\n1. `fetchUser()` is called.\n2. The function **pauses** and waits for the response.\n3. Once `user` is received, `fetchPosts()` is called.\n4. The function **pauses** again.\n5. Total time is the **sum** of all request times.\n\n**When to use this:** When the second request **depends** on the result of the first (e.g., you need the `userId` from the first call to fetch the posts in the second).\n\n---\n\n### 2. Promise.all (Parallel)\n`Promise.all` takes an array of promises and returns a single promise that resolves when **all** of the input promises have resolved.\n\n```javascript\nasync function parallel() {\n const [user, posts] = await Promise.all([\n fetchUser(), // Takes 1 second\n fetchPosts() // Takes 1 second\n ]);\n return { user, posts };\n}\n// Total time: ~1 second\n```\n\n**What happens here:**\n1. `fetchUser()` and `fetchPosts()` are both invoked **immediately**.\n2. Both network requests are sent to the server at roughly the same time.\n3. The `await` keyword pauses the function until **both** have finished.\n4. Total time is the duration of the **slowest** request.\n\n**When to use this:** When the tasks are independent of each other.\n\n---\n\n### Summary Comparison Table\n\n| Feature | Sequential (`await` $\\to$ `await`) | Parallel (`Promise.all`) |\n| :--- | :--- | :--- |\n| **Execution** | One after another | Simultaneously |\n| **Total Time** | Sum of all durations | Duration of the slowest task |\n| **Dependency** | Used when Task B needs Task A | Used when tasks are independent |\n| **Error Handling** | Stops at the first error encountered | Fails immediately if **any** promise rejects |\n\n### A Note on Error Handling\nOne"
},
{
"id": "go-slice-append",
"output": "In Go, a slice is not a container itself, but a **header** (a descriptor) that points to an **underlying array**. \n\nThe slice header consists of three things:\n1. **Pointer:** The address of the first element accessible to the slice.\n2. **Length (`len`):** The number of elements currently in the slice.\n3. **Capacity (`cap`):** The total number of elements in the underlying array, starting from the pointer.\n\nThe unexpected modification occurs because of how `append` interacts with this underlying array.\n\n### The Mechanism: Shared Storage\nWhen you create a new slice from an existing slice (e.g., `s2 := s1[1:3]`), Go does not copy the data. Instead, it creates a new slice header that points to the **same underlying array**.\n\nIf you `append` to `s2`, Go checks if there is enough **capacity** remaining in the underlying array to fit the new element.\n\n1. **If there is capacity:** Go writes the new value directly into the underlying array at the index `len(s2)`. Because `s1` shares that same array, any part of `s1` that overlaps with that index will now see the new value.\n2. **If there is NO capacity:** Go allocates a **new, larger array**, copies the existing elements over, and appends the new value there. At this point, `s2` now points to a completely different array than `s1`, and further changes to `s2` will not affect `s1`.\n\n### Code Example\nHere is a demonstration of this behavior:\n\n```go\npackage main\n\nimport \"fmt\"\n\nfunc main() {\n // Create a slice with length 3 and capacity 5\n s1 := make([]int, 3, 5) \n s1[0], s1[1], s1[2] = 1, 2, 3\n \n // s2 is a slice of s1. \n // It points to the same array, starting at index 0, with length 2.\n s2 := s1[0:2] \n \n fmt.Printf(\"s1: %v, len: %d, cap: %d\\n\", s1, len(s1), cap(s1))\n fmt.Printf(\"s2: %v, len: %d, cap: %d\\n\", s2, len(s2), cap(s2))\n\n // Append to s2. \n // Since s2 has a capacity of 5, it fits the new element in the shared array.\n s2 = append(s2, 99)\n\n fmt.Println(\"\\nAfter appending 9"
},
{
"id": "rust-lifetime",
"output": "In Rust, the compiler complains because of a fundamental rule: **The compiler must be able to guarantee that any reference you return will not point to memory that has been deleted (a \"dangling pointer\").**\n\nWhen you return a reference from a function, the compiler needs to know **where that reference comes from** and **how long it is valid**. Without explicit lifetime annotations, the compiler cannot determine this.\n\nHere is the detailed breakdown of why this happens.\n\n---\n\n### 1. The Problem: The \"Dangling Reference\"\nConsider this code that the compiler will reject:\n\n```rust\nfn get_first_word(s: &str) -> &str {\n let word = s.split_whitespace().next().unwrap();\n word // Error: missing lifetime specifier\n}\n```\n\nTo the human eye, it's obvious that the returned `&str` is just a slice of the input `s`. However, the Rust compiler views functions as isolated units. It looks at the signature:\n`fn get_first_word(s: &str) -> &str`\n\nThe compiler asks: **\"Is the returned reference tied to the input `s`, or is it tied to some other global variable, or is it a reference to a local variable created inside the function?\"**\n\nIf the compiler allowed this without a lifetime, you could accidentally do this:\n\n```rust\nfn get_bad_reference() -> &str {\n let s = String::from(\"Hello\");\n &s // This is a reference to a local variable\n} \n// 's' is dropped here. The returned reference now points to garbage memory!\n```\n\n### 2. The Solution: Lifetime Annotations\nLifetime annotations (like `<'a>`) do not change how long a variable lives; they simply **describe the relationship** between the lifetimes of different references.\n\nWhen you write:\n```rust\nfn get_first_word<'a>(s: &'a str) -> &'a str {\n s.split_whitespace().next().unwrap()\n}\n```\nYou are telling the compiler: *\"The reference I am returning will live **at least as long** as the reference I passed in.\"*\n\nNow, if you try to use the result after the original string has been deleted, the compiler can see the link and stop you at compile time.\n\n### 3. Why doesn't the compiler just \"guess\"? (Lifetime Elision)\nActually, the compiler **does** guess in many cases! This is called **Lifetime Elision**.\n\nIn the early days of Rust, you had to write `'a` everywhere. The community found it tedious, so the Rust team added rules that allow the compiler to omit them if the pattern is obvious.\n\nThe most common elision rule is: **If there is exactly one input"
},
{
"id": "python-gil",
"output": "The short answer is **no**. The Global Interpreter Lock (GIL) does not prevent concurrency; it prevents **true parallel execution of Python bytecode** on multiple CPU cores.\n\nTo understand this, you must first distinguish between **Concurrency** and **Parallelism**.\n\n### 1. Concurrency vs. Parallelism\n* **Concurrency** is about *dealing* with many things at once (structure). It means your program can start a task, pause it to work on another, and come back to it later.\n* **Parallelism** is about *doing* many things at once (execution). It requires multiple CPU cores running different pieces of code at the exact same millisecond.\n\n**The GIL prevents Parallelism for Python code, but it does not prevent Concurrency.**\n\n---\n\n### 2. When the GIL does NOT stop you\nThere are three main scenarios where you can still achieve high performance or concurrent execution despite the GIL:\n\n#### A. I/O-Bound Tasks (Threading)\nIf your program spends most of its time waiting (for a network response, a database query, or reading a file from a disk), the GIL is not a bottleneck. \n* When a Python thread performs an I/O operation, it **releases the GIL**.\n* While Thread A is waiting for a website to respond, Thread B can take the GIL and execute Python code.\n* **Tool:** `threading` module.\n\n#### B. CPU-Bound Tasks in C-Extensions (NumPy, Pandas, TensorFlow)\nMany high-performance libraries are written in C or C++. These libraries can explicitly release the GIL when performing heavy mathematical computations.\n* When you call `numpy.dot()` to multiply two massive matrices, NumPy drops the GIL, performs the math in optimized C/Fortran across all your CPU cores, and then re-acquires the GIL when it returns the result to Python.\n* **Tool:** NumPy, SciPy, PyTorch.\n\n#### C. True Parallelism (Multiprocessing)\nIf you have a CPU-heavy task written in pure Python (e.g., calculating primes), you can bypass the GIL entirely by using **Multiprocessing**.\n* Instead of multiple threads in one process, the `multiprocessing` module creates **entirely separate Python instances** (separate processes).\n* Each process has its own memory space and **its own GIL**. Therefore, they can run on different CPU cores simultaneously.\n* **Tool:** `multiprocessing` module.\n\n---\n\n### Summary Table\n\n| Task Type | Recommended Tool | Effect of GIL | Result |\n| :--- | :--- | :--- | :--- |\n| **I/O Bound** (API calls, DB) | `threading` or `asyncio` | Released during wait | **Concurrent** |\n| **CPU Bound**"
},
{
"id": "react-key",
"output": "React requires a unique `key` prop when rendering lists to help its **Reconciliation** process. \n\nIn simple terms, the `key` acts as a **stable identity** for an element. It tells React: *\"This specific piece of data belongs to this specific DOM element, regardless of where it moves in the list.\"*\n\nHere is the detailed breakdown of why this is necessary:\n\n### 1. Efficient DOM Updates (The \"Diffing\" Algorithm)\nReact maintains a \"Virtual DOM.\" When a component's state changes, React creates a new Virtual DOM tree and compares it with the old one to figure out the minimum number of changes needed to update the real browser DOM.\n\n**Without keys**, React uses a \"naive\" approach: it compares items by their **index (position)**. \n\n**Example Scenario:**\nImagine a list: `['Apple', 'Banana', 'Cherry']`.\nIf you add 'Apricot' to the **beginning** of the list, the new list is: `['Apricot', 'Apple', 'Banana', 'Cherry']`.\n\n* **Without keys:** React sees that the item at index 0 changed from Apple $\\rightarrow$ Apricot, index 1 changed from Banana $\\rightarrow$ Apple, and so on. React will re-render **every single item** in the list because it thinks every position has changed.\n* **With keys:** React sees that the element with `key=\"apple\"` simply moved from position 0 to position 1. It will simply insert the new 'Apricot' element at the top and **leave the others untouched**.\n\n### 2. Preserving Component State\nThis is the most critical reason for developers. If your list items are complex components (e.g., they have their own internal state, like an input field or a checkbox), using the index as a key can lead to severe bugs.\n\n**The Bug Scenario:**\n1. You have a list of three items. Each has an `<input>` field.\n2. You type \"Hello\" into the first input.\n3. You delete the first item from the list.\n4. **The Problem:** Because React is tracking by index, it thinks the first item (index 0) is still there, but its data changed. It will keep the \"Hello\" text in the first input box, even though that input now belongs to the item that was previously second.\n\nBy using a **unique ID** (like a database ID), React knows exactly which component was deleted and preserves the state of the remaining components correctly.\n\n### Summary: Best Practices for Keys\n\n| Key Choice | Recommendation | Why? |\n| :--- | :--- | :--- |\n| **Database ID** (`item.id`) | ✅ **Best** | Stable, unique, and doesn't change when the list is sorted or filtered. |"
}
]

View File

@@ -0,0 +1,42 @@
[
{
"id": "js-map-vs-foreach",
"output": "The key difference is that `.map()` **returns a new array** containing the results of the callback function, whereas `.forEach()` **returns `undefined`** and is used to execute side effects.\n\n**Example:**\n```javascript\nconst nums = [1, 2, 3];\n\n// .map() creates a new array\nconst doubled = nums.map(n => n * 2); // [2, 4, 6]\n\n// .forEach() just iterates\nnums.forEach(n => console.log(n)); // Logs 1, 2, 3; returns undefined\n```"
},
{
"id": "py-list-tuple",
"output": "Use a tuple when the data should be **immutable** (cannot be changed after creation) or when the data represents a **fixed structure** (like a record or a coordinate).\n\n**Key reasons to choose tuples:**\n1. **Data Integrity:** To ensure a collection of items remains constant throughout the program.\n2. **Dictionary Keys:** Tuples can be used as keys in a dictionary because they are hashable; lists cannot.\n3. **Performance:** Tuples are slightly faster and more memory-efficient than lists.\n\n**Example:**\n```python\n# Use a tuple for a fixed coordinate (x, y)\nlocation = (40.7128, 74.0060) \n\n# Use a list for a collection that will grow or change\ntodo_list = [\"Buy milk\", \"Clean room\"]\n```"
},
{
"id": "sql-inner-vs-left",
"output": "The key difference is that **INNER JOIN** returns only the rows where there is a match in both tables, while **LEFT JOIN** returns all rows from the left table and the matching rows from the right table (filling with `NULL` where no match exists).\n\n**Example:**\n* **INNER JOIN:** If you join `Customers` and `Orders`, you get only customers who have placed an order.\n* **LEFT JOIN:** You get all customers, including those who have never placed an order."
},
{
"id": "ts-type-vs-interface",
"output": "Use **interfaces** for defining the shape of objects and classes, especially when you need **declaration merging** or intend to use `extends`. Use **type aliases** for everything else, such as **unions, primitives, tuples, and intersections**.\n\n**Key Guidelines:**\n* **Interface:** Best for public APIs and object-oriented structures because they are extendable and provide better error messages in some IDEs.\n* **Type Alias:** Best for complex types (e.g., `type Status = 'Open' | 'Closed'`) or when you need to alias a primitive.\n\n**Example:**\n```typescript\n// Interface: Ideal for object shapes and extension\ninterface User { name: string }\ninterface Admin extends User { role: string }\n\n// Type Alias: Necessary for unions or primitives\ntype ID = string | number;\ntype Point = [number, number];\n```"
},
{
"id": "regex-bug",
"output": "The regex `[a-z]` only matches the **ASCII** range (English alphabet). It does not recognize Unicode characters, such as accented letters (`é`, `ö`) or non-Latin scripts, as lowercase.\n\nTo support non-ASCII lowercase letters, use the **Unicode property escape** `\\p{Ll}` (Lowercase Letter) with the `u` flag:\n\n```javascript\nconst regex = /^\\p{Ll}+$/u;\nconsole.log(regex.test('é')); // true\n```"
},
{
"id": "async-race",
"output": "Sequential `await` executes promises **serially**, meaning the second promise does not start until the first one resolves. `Promise.all` executes them **concurrently**, starting all promises simultaneously and waiting for all to complete.\n\n**Sequential (Slower):**\nTotal time = Time(P1) + Time(P2).\n```javascript\nconst a = await fetch('/api1'); // Starts now\nconst b = await fetch('/api2'); // Starts only after a finishes\n```\n\n**Promise.all (Faster):**\nTotal time = Time of the slowest promise.\n```javascript\nconst [a, b] = await Promise.all([fetch('/api1'), fetch('/api2')]); // Both start immediately\n```"
},
{
"id": "go-slice-append",
"output": "This happens because slices are headers pointing to a shared underlying array; if a slice has enough **capacity** (`cap`), `append` modifies the array in place rather than allocating a new one. If another slice points to that same memory location, it will see the updated value.\n\n**Example:**\n```go\na := make([]int, 3, 5) // len: 3, cap: 5\nb := a[:2] // b shares the same array as a\n\nb = append(b, 10) // b has capacity, so it overwrites a[2] with 10\nfmt.Println(a) // Output: [0 0 10] (a was modified)\n```\n\nTo prevent this, use the **full slice expression** `a[low:high:max]` to set the capacity of the sub-slice to its length, forcing `append` to allocate a new array."
},
{
"id": "rust-lifetime",
"output": "The compiler complains because it cannot guarantee that the data being referenced will outlive the reference itself, which would lead to a **dangling pointer**.\n\nWithout an explicit lifetime, the compiler doesn't know if the reference points to data owned by the function (which is dropped at the end of the scope) or data passed in as an argument.\n\n**Example of the error:**\n```rust\nfn get_str() -> &str {\n let s = String::from(\"hello\");\n &s // Error: returns a reference to data owned by the current function\n}\n```\nIn this case, `s` is dropped when the function returns, making the reference invalid. Explicit lifetimes (or returning an owned `String`) tell the compiler exactly how long the data remains valid."
},
{
"id": "python-gil",
"output": "No. The GIL (Global Interpreter Lock) prevents **true parallel execution of Python bytecode** on multiple CPU cores, but it does not prevent concurrency.\n\nPython achieves concurrency in two primary ways despite the GIL:\n\n1. **I/O-bound concurrency:** The GIL is released during I/O operations (e.g., network requests, disk reads), allowing other threads to run while one waits for a response.\n2. **Multiprocessing:** The `multiprocessing` module bypasses the GIL by creating separate Python processes, each with its own interpreter and GIL, enabling true parallelism across multiple CPU cores.\n\n**Example:**\n* **Threading:** Good for downloading 10 images simultaneously (I/O-bound).\n* **Multiprocessing:** Good for calculating 10 large prime numbers (CPU-bound)."
},
{
"id": "react-key",
"output": "React uses the `key` prop to uniquely identify elements during the **reconciliation** process. It allows React to track which items in a list have changed, been added, or been removed, ensuring it only updates the specific DOM elements that changed rather than re-rendering the entire list.\n\nWithout unique keys (or when using indexes as keys), React may incorrectly reuse state or DOM elements for the wrong data items when the list is reordered or filtered.\n\n**Example:**\n```javascript\n// Correct: Using a unique ID from the data\n{items.map(item => <li key={item.id}>{item.text}</li>)}\n\n// Risky: Using index (can cause bugs if the list is sorted/filtered)\n{items.map((item, index) => <li key={index}>{item.text}</li>)}\n```"
}
]

File diff suppressed because it is too large Load Diff