You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit b9cc573
Browse filesBrowse the repository at this point in the historyBrowse files
Resolve vetted production feedback across the JavaScript question set by replacing unsafe or stale resources, correcting runtime and storage explanations, and fixing localized terminology and examples. Regenerate the README so its embedded answers remain consistent with the question sources.
Copy file name to clipboardExpand all lines: README.md
+8-16Lines changed: 8 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -387,7 +387,7 @@ The event loop is a concept within the JavaScript runtime environment regarding
387
387
3. Once the asynchronous operation completes, its callback function is placed in the respective queues – task queues (also known as macrotask queues / callback queues) or microtask queues. We will refer to "task queue" as "macrotask queue" from here on to better differentiate from the microtask queue.
388
388
4. The event loop continuously monitors the call stack and executes items on the call stack. If/when the call stack is empty:
389
389
1. Microtask queue is processed. Microtasks include promise callbacks (`then`, `catch`, `finally`), `await` continuations, `MutationObserver` callbacks, and calls to `queueMicrotask()`. The event loop takes the first callback from the microtask queue and pushes it to the call stack for execution. This repeats until the microtask queue is empty.
390
-
2. Macrotask queue is processed. Macrotasks include web APIs like `setTimeout()`, HTTP requests, user interface event handlers like clicks, scrolls, etc. The event loop dequeues the first callback from the macrotask queue and pushes it onto the call stack for execution. However, after a macrotask queue callback is processed, the event loop does not proceed with the next macrotask yet! The event loop first checks the microtask queue. Checking the microtask queue is necessary as microtasks have higher priority than macrotask queue callbacks. The macrotask queue callback that was just executed could have added more microtasks!
390
+
2. Macrotask queue is processed. It contains tasks scheduled by the host, such as timer callbacks and user interface event callbacks. APIs such as `setTimeout()` and networking APIs are not themselves macrotasks; they arrange for callbacks or promise reactions to be queued when appropriate. The event loop dequeues the first callback from the macrotask queue and pushes it onto the call stack for execution. However, after a macrotask queue callback is processed, the event loop does not proceed with the next macrotask yet! The event loop first checks the microtask queue. Checking the microtask queue is necessary as microtasks have higher priority than macrotask queue callbacks. The macrotask queue callback that was just executed could have added more microtasks!
391
391
1. If the microtask queue is non-empty, process them as per the previous step.
392
392
2. If the microtask queue is empty, the next macrotask queue callback is processed. This repeats until the macrotask queue is empty.
393
393
5. This process continues indefinitely, allowing the JavaScript engine to handle both synchronous and asynchronous operations efficiently without blocking the call stack.
@@ -475,7 +475,7 @@ Here's a table summarizing the 3 client storage mechanisms.
475
475
| Lifespan | As specified | Until deleted | Until tab is closed |
476
476
| Persistent across browser sessions | If a future expiry date is set | Yes | No |
477
477
| Sent to server with every HTTP request | Yes, sent via `Cookie` header | No | No |
478
-
|Total capacity (per domain)|4KB | 5MB | 5MB|
478
+
|Typical storage limit | About 4 KB per cookie|About 5 MB per origin (browser-dependent) | About 5 MB per origin (browser-dependent)|
479
479
| Access | Across windows/tabs | Across windows/tabs | Same tab |
-**New JavaScript Methods**: For example, `Array.prototype.includes()`, `Object.assign()`, etc.
1332
1332
-**New APIs**: Such as `fetch()`, `Promise`, `IntersectionObserver`, etc. Modern browsers support these now, but for a long time they had to be polyfilled.
1333
1333
1334
-
Libraries and services for polyfills:
1334
+
A commonly used polyfill library is:
1335
1335
1336
1336
-**`core-js`**: A modular standard library for JavaScript which includes polyfills for a wide range of ECMAScript features.
1337
1337
@@ -1341,11 +1341,7 @@ Libraries and services for polyfills:
Prefer installing maintained polyfills as project dependencies and bundling them with your application instead of loading executable code from a third-party polyfill service at runtime.
@@ -3753,7 +3749,7 @@ The event loop is a concept within the JavaScript runtime environment regarding
3753
3749
3. Once the asynchronous operation completes, its callback function is placed in the respective queues – task queues (also known as macrotask queues / callback queues) or microtask queues. We will refer to "task queue" as "macrotask queue" from here on to better differentiate from the microtask queue.
3754
3750
4. The event loop continuously monitors the call stack and executes items on the call stack. If/when the call stack is empty:
3755
3751
1. Microtask queue is processed. Microtasks include promise callbacks (`then`, `catch`, `finally`), `await` continuations, `MutationObserver` callbacks, and calls to `queueMicrotask()`. The event loop takes the first callback from the microtask queue and pushes it to the call stack for execution. This repeats until the microtask queue is empty.
3756
-
2. Macrotask queue is processed. Macrotasks include web APIs like `setTimeout()`, HTTP requests, user interface event handlers like clicks, scrolls, etc. The event loop dequeues the first callback from the macrotask queue and pushes it onto the call stack for execution. However, after a macrotask queue callback is processed, the event loop does not proceed with the next macrotask yet! The event loop first checks the microtask queue. Checking the microtask queue is necessary as microtasks have higher priority than macrotask queue callbacks. The macrotask queue callback that was just executed could have added more microtasks!
3752
+
2. Macrotask queue is processed. It contains tasks scheduled by the host, such as timer callbacks and user interface event callbacks. APIs such as `setTimeout()` and networking APIs are not themselves macrotasks; they arrange for callbacks or promise reactions to be queued when appropriate. The event loop dequeues the first callback from the macrotask queue and pushes it onto the call stack for execution. However, after a macrotask queue callback is processed, the event loop does not proceed with the next macrotask yet! The event loop first checks the microtask queue. Checking the microtask queue is necessary as microtasks have higher priority than macrotask queue callbacks. The macrotask queue callback that was just executed could have added more microtasks!
3757
3753
1. If the microtask queue is non-empty, process them as per the previous step.
3758
3754
2. If the microtask queue is empty, the next macrotask queue callback is processed. This repeats until the macrotask queue is empty.
3759
3755
5. This process continues indefinitely, allowing the JavaScript engine to handle both synchronous and asynchronous operations efficiently without blocking the call stack.
@@ -5032,7 +5028,7 @@ Here's a table summarizing the 3 client storage mechanisms.
5032
5028
| Lifespan | As specified | Until deleted | Until tab is closed |
5033
5029
| Persistent across browser sessions | If a future expiry date is set | Yes | No |
5034
5030
| Sent to server with every HTTP request | Yes, sent via `Cookie` header | No | No |
5035
-
|Total capacity (per domain)|4KB | 5MB | 5MB|
5031
+
|Typical storage limit | About 4 KB per cookie|About 5 MB per origin (browser-dependent) | About 5 MB per origin (browser-dependent)|
5036
5032
| Access | Across windows/tabs | Across windows/tabs | Same tab |
-**New JavaScript Methods**: For example, `Array.prototype.includes()`, `Object.assign()`, etc.
5327
5323
-**New APIs**: Such as `fetch()`, `Promise`, `IntersectionObserver`, etc. Modern browsers support these now, but for a long time they had to be polyfilled.
5328
5324
5329
-
Libraries and services for polyfills:
5325
+
A commonly used polyfill library is:
5330
5326
5331
5327
-**`core-js`**: A modular standard library for JavaScript which includes polyfills for a wide range of ECMAScript features.
5332
5328
@@ -5336,11 +5332,7 @@ Libraries and services for polyfills:
Prefer installing maintained polyfills as project dependencies and bundling them with your application instead of loading executable code from a third-party polyfill service at runtime.
Copy file name to clipboardExpand all lines: questions/can-you-offer-a-use-case-for-the-new-arrow-function-syntax-how-does-this-new-syntax-differ-from-other-functions/en-US.mdx
+4-3Lines changed: 4 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -48,11 +48,12 @@ function Timer() {
48
48
}
49
49
50
50
consttimer=newTimer();
51
-
timer.increment(); // 1
52
-
timer.increment(); // 2
51
+
constincrement=timer.increment;
52
+
increment(); // 1
53
+
increment(); // 2
53
54
```
54
55
55
-
In the example above, using a traditional function for `increment` would lose the correct `this`context when called, requiring additional steps like `bind` to fix it.
56
+
In the example above, `increment` is called without `timer` as its receiver, but the arrow function still uses the `this`value captured by the `Timer` constructor. A traditional function would lose that context when detached this way unless it was explicitly bound.
Copy file name to clipboardExpand all lines: questions/can-you-offer-a-use-case-for-the-new-arrow-function-syntax-how-does-this-new-syntax-differ-from-other-functions/zh-CN.mdx
@@ -50,7 +50,7 @@ The following sections dive deeper into each client storage mechanism.
50
50
51
51
Cookies are used to store small pieces of data on the client side that can be sent back to the server with every HTTP request.
52
52
53
-
-**Storage capacity**: Limited to around 4KB for all cookies.
53
+
-**Storage capacity**: Limited to around 4 KB per cookie. Browsers also limit how many cookies can be stored per domain.
54
54
-**Lifespan**: Cookies can have a specific expiration date set using the `Expires` or `Max-Age` attributes. If no expiration date is set, the cookie is deleted when the browser is closed (session cookie).
55
55
-**Access**: Cookies are domain-specific and can be shared across different pages and subdomains within the same domain.
56
56
-**Security**: Cookies can be marked as `HttpOnly` to prevent access from JavaScript, reducing the risk of XSS attacks. They can also be secured with the `Secure` flag to ensure they are sent only when HTTPS is used.
Copy file name to clipboardExpand all lines: questions/describe-the-difference-between-a-cookie-sessionstorage-and-localstorage/pt-BR.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,7 @@ Cookies, `localStorage`, and `sessionStorage`, são todos:
24
24
| Vencimento | Definir manualmente | Para sempre | Ao fechar a aba |
25
25
| Persistente através de sessões do navegador | Depende se a expiração está definida | Sim | Não |
26
26
| Enviado para o servidor com cada solicitação HTTP | Os cookies são automaticamente enviados via cabeçalho `Cookie`| Não | Não |
27
-
|Capacidade (por domínio) | 4kb | 5MB | 5MB|
27
+
|Limite típico de armazenamento | Cerca de 4 KB por cookie | Cerca de 5 MB por origem (varia conforme o navegador) | Cerca de 5 MB por origem (varia conforme o navegador)|
Também existem outros mecanismos de armazenamento do lado do cliente, como [IndexedDB](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API) que é mais poderoso do que as tecnologias acima mencionadas, mas mais complicado de usar.
Copy file name to clipboardExpand all lines: questions/explain-the-concept-of-error-propagation-in-javascript/zh-CN.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -102,4 +102,4 @@ async function b() {
102
102
103
103
-[MDN Web Docs: Error handling](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Control_flow_and_error_handling#exception_handling_statements)
Copy file name to clipboardExpand all lines: questions/how-can-you-implement-secure-authentication-and-authorization-in-javascript-applications/en-US.mdx
Copy file name to clipboardExpand all lines: questions/how-can-you-implement-secure-authentication-and-authorization-in-javascript-applications/zh-CN.mdx
0 commit comments