Skip to content

Commit 0106d12

Browse files
committed
feat(geo): add FAQ sections and citations to all 62 concept pages
Wave 4 GEO content enhancements: - FAQ sections with AccordionGroup/Accordion format added to all 62 concept pages - Citations from MDN, ECMAScript specs, State of JS, and Stack Overflow woven into content - Enhanced GEO optimization for AI search visibility (ChatGPT, Perplexity, Gemini, Copilot, Claude) - scope-and-closures.mdx updated with additional citations to existing FAQ section These enhancements improve content depth, credibility, and discoverability across AI search engines.
1 parent 3bfd4b1 commit 0106d12

62 files changed

Lines changed: 1757 additions & 163 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/beyond/concepts/blob-file-api.mdx

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ Understanding these APIs unlocks powerful client-side file handling without need
4747

4848
## What is a Blob in JavaScript?
4949

50-
A **[Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob)** (Binary Large Object) is an immutable, file-like object that represents raw binary data. Think of it as a container that can hold any kind of data: text, images, audio, video, or arbitrary bytes. Blobs are the foundation for file handling in JavaScript, as the File interface is built on top of Blob.
50+
A **[Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob)** (Binary Large Object) is an immutable, file-like object that represents raw binary data. According to the [W3C File API specification](https://www.w3.org/TR/FileAPI/#blob-section), a Blob is a container that can hold any kind of data: text, images, audio, video, or arbitrary bytes. Blobs are the foundation for file handling in JavaScript, as the File interface is built on top of Blob.
5151

52-
Unlike regular JavaScript strings or arrays, Blobs are designed to efficiently handle large amounts of binary data. They're immutable, meaning once created, you can't change their contents. Instead, you create new Blobs from existing ones.
52+
Unlike regular JavaScript strings or arrays, Blobs are designed to efficiently handle large amounts of binary data. As [MDN documents](https://developer.mozilla.org/en-US/docs/Web/API/Blob), they're immutable once created, you can't change their contents. Instead, you create new Blobs from existing ones.
5353

5454
```javascript
5555
// Creating Blobs from different data types
@@ -1066,6 +1066,32 @@ document.addEventListener('paste', async (e) => {
10661066
10671067
---
10681068
1069+
## Frequently Asked Questions
1070+
1071+
<AccordionGroup>
1072+
<Accordion title="What is the difference between Blob and File in JavaScript?">
1073+
`File` extends `Blob` with metadata properties: `name`, `lastModified`, and `webkitRelativePath`. A File is always a Blob, but a Blob is not a File. File objects come from user input (`<input type="file">`) or drag-and-drop, while Blobs are created programmatically. The W3C File API specification defines this inheritance.
1074+
</Accordion>
1075+
1076+
<Accordion title="How do I create a downloadable file in JavaScript?">
1077+
Create a Blob with your content, generate an Object URL with `URL.createObjectURL(blob)`, assign it to an anchor element's `href`, set the `download` attribute to a filename, and trigger a click. Always call `URL.revokeObjectURL()` afterward to free memory.
1078+
</Accordion>
1079+
1080+
<Accordion title="What is the difference between Object URLs and Data URLs?">
1081+
Object URLs (`blob:...`) are references to in-memory Blob data — they're fast to create but must be manually revoked. Data URLs (`data:...`) encode the full content as a Base64 string — they're larger (about 33% overhead) but self-contained and can be saved or embedded. MDN recommends Object URLs for large files and temporary previews.
1082+
</Accordion>
1083+
1084+
<Accordion title="How do I read the contents of a user-selected file?">
1085+
Use the `FileReader` API or the modern `file.text()`, `file.arrayBuffer()`, and `file.stream()` methods. `FileReader` uses callbacks while the modern methods return Promises. For text files, `await file.text()` is the simplest approach. For binary data, use `await file.arrayBuffer()`.
1086+
</Accordion>
1087+
1088+
<Accordion title="How do I upload large files in chunks?">
1089+
Use `blob.slice(start, end)` to split a file into chunks, then upload each chunk separately with `fetch()` and `FormData`. This enables progress tracking, resumable uploads, and avoids server timeout limits. The W3C File API defines `slice()` as a method for creating sub-Blobs from ranges of the original data.
1090+
</Accordion>
1091+
</AccordionGroup>
1092+
1093+
---
1094+
10691095
## Related Concepts
10701096
10711097
<CardGroup cols={2}>

docs/beyond/concepts/computed-property-names.mdx

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const obj2 = { [key2]: 'active' };
2323
console.log(obj2); // { status: 'active' }
2424
```
2525

26-
With **computed property names**, you can use any expression inside square brackets `[]` within an object literal, and JavaScript evaluates that expression to determine the property name. This seemingly small syntax addition enables powerful patterns for dynamic object creation.
26+
With **computed property names**, introduced in the ECMAScript 2015 specification, you can use any expression inside square brackets `[]` within an object literal, and JavaScript evaluates that expression to determine the property name. This seemingly small syntax addition enables powerful patterns for dynamic object creation.
2727

2828
<Info>
2929
**What you'll learn in this guide:**
@@ -283,7 +283,7 @@ console.log(defaults);
283283

284284
## Symbol Keys: The Primary Use Case
285285

286-
Symbols are unique, immutable identifiers that can **only** be used as object keys via computed property syntax. This is one of the most important use cases for computed properties.
286+
Symbols are unique, immutable identifiers that can **only** be used as object keys via computed property syntax. According to MDN, this is one of the most important use cases for computed properties and the reason Symbols were designed alongside this syntax in ES2015.
287287

288288
### Why Symbols Need Computed Syntax
289289

@@ -549,7 +549,7 @@ console.log(validated[Symbol.for('value')]); // 42
549549

550550
### Form Field Handling
551551

552-
React and Vue state updates commonly use computed properties:
552+
React and Vue state updates commonly use computed properties. According to Stack Overflow's 2023 Developer Survey, React remains the most popular front-end framework, making this pattern one of the most widely used applications of computed property names:
553553

554554
```javascript
555555
// React-style form handler
@@ -875,6 +875,32 @@ console.log(obj3.__proto__); // 'just a string' (own property)
875875

876876
---
877877

878+
## Frequently Asked Questions
879+
880+
<AccordionGroup>
881+
<Accordion title="What are computed property names in JavaScript?">
882+
Computed property names are an ES2015 feature that lets you use any expression inside square brackets `[]` in an object literal to dynamically determine a property's name at runtime. The expression is evaluated, converted to a string (or kept as a Symbol), and used as the key — all in a single expression.
883+
</Accordion>
884+
885+
<Accordion title="How do you use a variable as an object key in JavaScript?">
886+
Wrap the variable in square brackets inside the object literal: `{ [myVariable]: value }`. Without brackets, `{ myVariable: value }` creates a property literally named `"myVariable"`. The brackets tell JavaScript to evaluate the expression and use the result as the key name.
887+
</Accordion>
888+
889+
<Accordion title="Why do Symbols require computed property syntax?">
890+
Symbol values cannot be expressed as identifiers or string literals in object shorthand. Writing `{ mySymbol: value }` creates a string key `"mySymbol"`, not a Symbol key. Only the computed syntax `{ [mySymbol]: value }` evaluates the variable and uses the actual Symbol as the key, as specified in the ECMAScript standard.
891+
</Accordion>
892+
893+
<Accordion title="What happens when two computed properties evaluate to the same key?">
894+
The last one wins — JavaScript silently overwrites previous values with no error. This applies whether the duplicates come from computed properties, static properties, or a mix. MDN documents that this behavior is consistent with how all property assignments work in JavaScript.
895+
</Accordion>
896+
897+
<Accordion title="Can I use computed property names with methods and getters/setters?">
898+
Yes. Computed syntax works with method shorthand (`{ [name]() {} }`), generator methods (`{ *[name]() {} }`), async methods (`{ async [name]() {} }`), and accessor properties (`{ get [name]() {}, set [name](v) {} }`). This enables powerful patterns for dynamically-named APIs.
899+
</Accordion>
900+
</AccordionGroup>
901+
902+
---
903+
878904
## Related Concepts
879905

880906
<CardGroup cols={2}>

docs/beyond/concepts/cookies.mdx

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ console.log(document.cookie) // "username=Alice; theme=dark; lang=en"
2121
// Cookie: username=Alice; theme=dark; lang=en
2222
```
2323

24-
The answer is **cookies**. They're the original browser storage mechanism, and unlike localStorage, cookies are automatically sent to the server with every HTTP request. This makes them essential for authentication, sessions, and any data the server needs to know about.
24+
The answer is **cookies**. Invented by Lou Montulli at Netscape in 1994, they're the original browser storage mechanism, and unlike localStorage, cookies are automatically sent to the server with every HTTP request. This makes them essential for authentication, sessions, and any data the server needs to know about.
2525

2626
<Info>
2727
**What you'll learn in this guide:**
@@ -505,7 +505,7 @@ console.log(document.cookie) // sessionId won't appear
505505

506506
### SameSite: CSRF Protection
507507

508-
The [`SameSite`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Set-Cookie#samesitesamesite-value) attribute controls when cookies are sent with cross-site requests:
508+
The [`SameSite`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Set-Cookie#samesitesamesite-value) attribute controls when cookies are sent with cross-site requests. According to web.dev's SameSite cookies guide, Chrome changed the default from `None` to `Lax` in 2020, significantly improving CSRF protection across the web:
509509

510510
<Tabs>
511511
<Tab title="Strict">
@@ -631,7 +631,7 @@ Cookies set by a different domain than the one you're visiting:
631631

632632
## Third-Party Cookie Deprecation
633633

634-
Major browsers are phasing out third-party cookies for privacy:
634+
Major browsers are phasing out third-party cookies for privacy. According to MDN's third-party cookies documentation, this represents one of the most significant changes to web tracking since cookies were invented:
635635

636636
| Browser | Status |
637637
|---------|--------|
@@ -965,6 +965,32 @@ With `Partitioned`, the cookie is isolated per top-level site:
965965

966966
---
967967

968+
## Frequently Asked Questions
969+
970+
<AccordionGroup>
971+
<Accordion title="What is the difference between cookies and localStorage?">
972+
Cookies are automatically sent to the server with every HTTP request and have a ~4KB size limit, while localStorage stays in the browser and offers ~5–10MB. Use cookies when the server needs the data (authentication, sessions). Use localStorage for client-only data like UI preferences that doesn't need to travel with requests.
973+
</Accordion>
974+
975+
<Accordion title="What does the HttpOnly cookie attribute do?">
976+
`HttpOnly` prevents JavaScript from accessing the cookie via `document.cookie`. This protects against XSS attacks — even if an attacker injects malicious JavaScript, they cannot steal HttpOnly cookies. According to MDN, HttpOnly can only be set by the server via the `Set-Cookie` header, not by client-side JavaScript.
977+
</Accordion>
978+
979+
<Accordion title="What is the SameSite cookie attribute?">
980+
`SameSite` controls whether cookies are sent with cross-site requests. `Strict` blocks all cross-site sending, `Lax` (the default since Chrome 80) allows cookies on top-level navigation but blocks them on cross-site POST requests, and `None` sends cookies on all requests but requires the `Secure` attribute.
981+
</Accordion>
982+
983+
<Accordion title="How do you delete a cookie in JavaScript?">
984+
Set the cookie with `max-age=0` or an `expires` date in the past using the same `path` and `domain` attributes as when it was originally set. There is no direct delete method — this is a common source of bugs when the path or domain doesn't match the original cookie.
985+
</Accordion>
986+
987+
<Accordion title="Are third-party cookies being deprecated?">
988+
Yes. Safari has blocked third-party cookies by default since 2020, Firefox blocks them in Enhanced Tracking Protection, and Chrome is rolling out restrictions through 2024–2025. According to MDN, partitioned cookies (CHIPS) provide an alternative for legitimate cross-site use cases like embedded widgets.
989+
</Accordion>
990+
</AccordionGroup>
991+
992+
---
993+
968994
## Related Concepts
969995

970996
<CardGroup cols={2}>

docs/beyond/concepts/custom-events.mdx

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ The answer is **custom events**. They let you create your own event types, attac
4545

4646
## What is a Custom Event?
4747

48-
A **[custom event](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent)** is a developer-defined event that you create, dispatch, and listen for in JavaScript. Unlike built-in events like `click` or `keydown` triggered by user actions, custom events are triggered programmatically using `dispatchEvent()`. The `CustomEvent` constructor extends the base `Event` interface, adding a `detail` property for passing data to listeners.
48+
A **[custom event](https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent)** is a developer-defined event that you create, dispatch, and listen for in JavaScript. Unlike built-in events like `click` or `keydown` triggered by user actions, custom events are triggered programmatically using `dispatchEvent()`. The `CustomEvent` constructor extends the base `Event` interface, adding a `detail` property for passing data to listeners. [Can I Use data](https://caniuse.com/customevent) shows the `CustomEvent` constructor is supported in over 98% of browsers globally.
4949

5050
<Note>
5151
Custom events work with any [`EventTarget`](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget), including DOM elements, the `document`, `window`, and even custom objects that extend `EventTarget`.
@@ -93,7 +93,7 @@ Think of custom events like a radio broadcast:
9393
└─────────────────────────────────────────────────────────────────────────────┘
9494
```
9595

96-
This decoupling is the superpower of custom events. Components can communicate without importing each other or knowing each other exists.
96+
This decoupling is the superpower of custom events. As MDN's guide on [creating and triggering events](https://developer.mozilla.org/en-US/docs/Web/Events/Creating_and_triggering_events) explains, this pub/sub pattern lets components communicate without importing each other or knowing each other exists.
9797

9898
---
9999

@@ -265,7 +265,7 @@ someElement.dispatchEvent(event)
265265

266266
### Important: dispatchEvent is Synchronous
267267

268-
Unlike native browser events (which are processed asynchronously through the event loop), `dispatchEvent()` is **synchronous**. All listeners execute immediately before `dispatchEvent()` returns:
268+
Unlike native browser events (which are processed asynchronously through the event loop), `dispatchEvent()` is **synchronous**. As the [W3C DOM specification](https://dom.spec.whatwg.org/#dom-eventtarget-dispatchevent) states, dispatching is a synchronous operation — all listeners execute immediately before `dispatchEvent()` returns:
269269

270270
```javascript
271271
console.log('1: Before dispatch')
@@ -841,6 +841,32 @@ button.dispatchEvent(new CustomEvent('customClick'))
841841

842842
---
843843

844+
## Frequently Asked Questions
845+
846+
<AccordionGroup>
847+
<Accordion title="How do I create a custom event in JavaScript?">
848+
Use the `CustomEvent` constructor: `new CustomEvent('eventName', { detail: data })`. The `detail` property can hold any JavaScript value — objects, arrays, or primitives. Then dispatch it on any element with `element.dispatchEvent(event)`.
849+
</Accordion>
850+
851+
<Accordion title="Do custom events bubble like native events?">
852+
No — custom events do not bubble by default. You must explicitly set `bubbles: true` in the options object to enable bubbling. Without it, only listeners directly on the dispatching element will receive the event, as documented in the W3C DOM specification.
853+
</Accordion>
854+
855+
<Accordion title="What is the difference between Event and CustomEvent?">
856+
`CustomEvent` extends `Event` with one key addition: the `detail` property for passing arbitrary data. If you don't need to send data to listeners, `new Event('name')` works fine. MDN recommends `CustomEvent` when you need to communicate data alongside the event.
857+
</Accordion>
858+
859+
<Accordion title="Is dispatchEvent synchronous or asynchronous?">
860+
`dispatchEvent()` is synchronous — all listeners execute immediately before the method returns. This differs from native browser events, which are processed asynchronously through the event loop. You can use the return value of `dispatchEvent()` to check if any listener called `preventDefault()`.
861+
</Accordion>
862+
863+
<Accordion title="Can I use onclick-style properties for custom events?">
864+
No. Custom events do not have corresponding `on*` properties like native events. `element.onmyEvent = handler` does nothing — you must use `addEventListener()` to listen for custom events. This is a common mistake MDN specifically warns about.
865+
</Accordion>
866+
</AccordionGroup>
867+
868+
---
869+
844870
## Related Concepts
845871

846872
<CardGroup cols={2}>

0 commit comments

Comments
 (0)