Skip to content

Commit 5b25ee2

Browse files
committed
Removed redundant 'JavaScript' mentions as per maintainer feedback
1 parent 4a4f772 commit 5b25ee2

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,8 @@
512512
| 474 | [What is module scope in JavaScript?](#what-is-module-scope-in-javascript) |
513513
| 475 | [What are shadowing and illegal shadowing?](#what-are-shadowing-and-illegal-shadowing) |
514514
| 476 | [Why is it important to remove event listeners after use?](#why-is-it-important-to-remove-event-listeners-after-use) |
515-
| 477 | [What is the difference between setTimeout and requestAnimationFrame in JavaScript, and when should you use each?](#what-is-the-difference-between-settimeout-and-requestanimationframe-in-javascript-and-when-should-you-use-each) |
515+
| 477 | [What is the difference between setTimeout and requestAnimationFrame, and when should you use each?](#what-is-the-difference-between-settimeout-and-requestanimationframe-and-when-should-you-use-each) |
516+
516517
<!-- TOC_END -->
517518

518519
<!-- QUESTIONS_START -->
@@ -9533,22 +9534,20 @@ Common use cases and benefits:
95339534
95349535
**[⬆ Back to Top](#table-of-contents)**
95359536
9536-
477. ### What is the difference between setTimeout and requestAnimationFrame in JavaScript, and when should you use each?
9537-
9538-
In JavaScript:
9537+
477. ### What is the difference between setTimeout and requestAnimationFrame, and when should you use each?
95399538
9540-
- `setTimeout` schedules a function to execute after a specified delay (in milliseconds), regardless of the browser’s rendering cycle.
9541-
- `requestAnimationFrame` schedules a function to run **before the next repaint**, making it ideal for smooth animations and UI updates.
9539+
- `setTimeout` schedules a function to execute after a specified delay (in milliseconds), independent of the browser’s rendering cycle.
9540+
- `requestAnimationFrame` schedules a function to run **right before the next repaint**, making it ideal for smooth animations and efficient visual updates.
95429541
95439542
**When to use each:**
95449543
9545-
1. **setTimeout**:
9546-
- Use for delayed tasks or operations that do not need to sync with the screen refresh.
9547-
- Example: Polling a server every few seconds.
9544+
1. **setTimeout**
9545+
- Use for delayed tasks or operations that don’t need to sync with the display refresh rate.
9546+
- Example: Triggering periodic updates, polling data, or debouncing inputs.
95489547
9549-
2. **requestAnimationFrame**:
9550-
- Use for animations or visual updates to ensure smooth, performant rendering.
9551-
- Example: Animating a moving object on the screen.
9548+
2. **requestAnimationFrame**
9549+
- Use for animations or visual changes tied to frame rendering for smoother performance.
9550+
- Example: Moving an element across the screen or updating canvas drawings.
95529551
95539552
**Example:**
95549553
@@ -9566,8 +9565,9 @@ function animate() {
95669565
}
95679566
requestAnimationFrame(animate);
95689567
```
9568+
95699569
**[⬆ Back to Top](#table-of-contents)**
9570-
9570+
95719571
95729572
95739573

0 commit comments

Comments
 (0)