|  | 
| 1 | 1 | 
 | 
| 2 |  | -# javascript-questions-pro (590 questions) | 
|  | 2 | +# javascript-questions-pro (619 questions) | 
| 3 | 3 | 
 | 
| 4 | 4 | ## [Levels](./level/) (4) | 
| 5 | 5 | - [basic](./level/basic) | 
| 6 | 6 | - [intermediate](./level/intermediate) | 
| 7 | 7 | - [advanced](./level/advanced) | 
| 8 | 8 | - [beginner](./level/beginner) | 
| 9 | 9 | 
 | 
| 10 |  | -## [Themes](./theme/) (211)   | 
|  | 10 | +## [Themes](./theme/) (218)   | 
| 11 | 11 | - [indexeddb](./theme/indexeddb) | 
| 12 | 12 | - [db](./theme/db) | 
| 13 | 13 | - [storage](./theme/storage) | 
|  | 
| 219 | 219 | - [headless testing](./theme/headless_testing) | 
| 220 | 220 | - [async await](./theme/async_await) | 
| 221 | 221 | - [express js](./theme/express_js) | 
|  | 222 | +- [algorithms](./theme/algorithms) | 
|  | 223 | +- [weakmap](./theme/weakmap) | 
|  | 224 | +- [v8](./theme/v8) | 
|  | 225 | +- [devtools](./theme/devtools) | 
|  | 226 | +- [animation](./theme/animation) | 
|  | 227 | +- [multithreading](./theme/multithreading) | 
|  | 228 | +- [async](./theme/async) | 
| 222 | 229 | 
 | 
| 223 | 230 | ## [Tutorials with Videos](./video/) (191) | 
| 224 | 231 | - [What is IndexedDB](https://www.tiktok.com/@jsmentoring/photo/7448276165661314336) | 
| @@ -12684,4 +12691,294 @@ Promise.reject(new Error('Unhandled error')); | 
| 12684 | 12691 | 
 | 
| 12685 | 12692 | 
 | 
| 12686 | 12693 | 
 | 
|  | 12694 | +--- | 
|  | 12695 | +
 | 
|  | 12696 | +### What is garbage collection? | 
|  | 12697 | +
 | 
|  | 12698 | +Garbage collection is an automatic memory management feature in JavaScript that frees memory occupied by objects no longer in use. | 
|  | 12699 | +
 | 
|  | 12700 | +**Tags**: [beginner](./level/beginner), [JavaScript](./theme/javascript), [Memory Management](./theme/memory_management) | 
|  | 12701 | +
 | 
|  | 12702 | +
 | 
|  | 12703 | +
 | 
|  | 12704 | +--- | 
|  | 12705 | +
 | 
|  | 12706 | +### How does garbage collection work? | 
|  | 12707 | +
 | 
|  | 12708 | +Garbage collection in JavaScript is performed by the JavaScript engine, which identifies and removes objects that are no longer reachable from the root (e.g., global object or stack). | 
|  | 12709 | +
 | 
|  | 12710 | +**Tags**: [intermediate](./level/intermediate), [JavaScript](./theme/javascript), [Memory Management](./theme/memory_management), [Algorithms](./theme/algorithms) | 
|  | 12711 | +
 | 
|  | 12712 | +
 | 
|  | 12713 | +
 | 
|  | 12714 | +--- | 
|  | 12715 | +
 | 
|  | 12716 | +### Types of garbage collection algorithms | 
|  | 12717 | +
 | 
|  | 12718 | +Common garbage collection algorithms include reference counting, mark-and-sweep, and generational garbage collection. | 
|  | 12719 | +
 | 
|  | 12720 | +**Tags**: [advanced](./level/advanced), [JavaScript](./theme/javascript), [Memory Management](./theme/memory_management), [Performance](./theme/performance) | 
|  | 12721 | +
 | 
|  | 12722 | +
 | 
|  | 12723 | +
 | 
|  | 12724 | +--- | 
|  | 12725 | +
 | 
|  | 12726 | +### What is the mark-and-sweep algorithm? | 
|  | 12727 | +
 | 
|  | 12728 | +The mark-and-sweep algorithm identifies active objects (mark phase) and removes unreferenced objects (sweep phase), freeing up memory. | 
|  | 12729 | +
 | 
|  | 12730 | +**Tags**: [intermediate](./level/intermediate), [JavaScript](./theme/javascript), [Memory Management](./theme/memory_management) | 
|  | 12731 | +
 | 
|  | 12732 | +
 | 
|  | 12733 | +
 | 
|  | 12734 | +--- | 
|  | 12735 | +
 | 
|  | 12736 | +### How to prevent memory leaks? | 
|  | 12737 | +
 | 
|  | 12738 | +Avoid circular references, remove event listeners, clear intervals, and use weak references where appropriate to prevent memory leaks. | 
|  | 12739 | +
 | 
|  | 12740 | +**Tags**: [advanced](./level/advanced), [JavaScript](./theme/javascript), [Performance](./theme/performance), [Optimization](./theme/optimization) | 
|  | 12741 | +
 | 
|  | 12742 | +
 | 
|  | 12743 | +
 | 
|  | 12744 | +--- | 
|  | 12745 | +
 | 
|  | 12746 | +### What are weak references? | 
|  | 12747 | +
 | 
|  | 12748 | +Weak references, such as those used in `WeakMap` and `WeakSet`, allow garbage collection of objects when they are no longer reachable elsewhere. | 
|  | 12749 | +
 | 
|  | 12750 | +**Tags**: [advanced](./level/advanced), [JavaScript](./theme/javascript), [Memory Management](./theme/memory_management), [WeakMap](./theme/weakmap) | 
|  | 12751 | +
 | 
|  | 12752 | +
 | 
|  | 12753 | +
 | 
|  | 12754 | +--- | 
|  | 12755 | +
 | 
|  | 12756 | +### Does JavaScript have manual garbage collection? | 
|  | 12757 | +
 | 
|  | 12758 | +No, JavaScript relies on automatic garbage collection managed by the engine, such as V8 in Chrome and Node.js. | 
|  | 12759 | +
 | 
|  | 12760 | +**Tags**: [beginner](./level/beginner), [JavaScript](./theme/javascript), [Memory Management](./theme/memory_management) | 
|  | 12761 | +
 | 
|  | 12762 | +
 | 
|  | 12763 | +
 | 
|  | 12764 | +--- | 
|  | 12765 | +
 | 
|  | 12766 | +### How does garbage collection affect performance? | 
|  | 12767 | +
 | 
|  | 12768 | +Garbage collection can cause performance hiccups due to unpredictable pauses. Proper memory management can help minimize these interruptions. | 
|  | 12769 | +
 | 
|  | 12770 | +**Tags**: [intermediate](./level/intermediate), [JavaScript](./theme/javascript), [Performance](./theme/performance) | 
|  | 12771 | +
 | 
|  | 12772 | +
 | 
|  | 12773 | +
 | 
|  | 12774 | +--- | 
|  | 12775 | +
 | 
|  | 12776 | +### Can you force garbage collection in JavaScript? | 
|  | 12777 | +
 | 
|  | 12778 | +In most cases, you cannot manually trigger garbage collection. However, in some environments like Node.js, you can use `global.gc()` if the `--expose-gc` flag is enabled. | 
|  | 12779 | +
 | 
|  | 12780 | +**Tags**: [advanced](./level/advanced), [JavaScript](./theme/javascript), [Memory Management](./theme/memory_management), [V8](./theme/v8) | 
|  | 12781 | +
 | 
|  | 12782 | +
 | 
|  | 12783 | +
 | 
|  | 12784 | +--- | 
|  | 12785 | +
 | 
|  | 12786 | +### What tools can help detect memory leaks? | 
|  | 12787 | +
 | 
|  | 12788 | +Tools like Chrome DevTools, Node.js heap snapshots, and profiling tools can help identify memory leaks in JavaScript applications. | 
|  | 12789 | +
 | 
|  | 12790 | +**Tags**: [advanced](./level/advanced), [JavaScript](./theme/javascript), [Debugging](./theme/debugging), [Performance](./theme/performance) | 
|  | 12791 | +
 | 
|  | 12792 | +
 | 
|  | 12793 | +
 | 
|  | 12794 | +--- | 
|  | 12795 | +
 | 
|  | 12796 | +### What is performance debugging? | 
|  | 12797 | +
 | 
|  | 12798 | +Performance debugging involves identifying and fixing bottlenecks in JavaScript code to improve execution speed and efficiency. | 
|  | 12799 | +
 | 
|  | 12800 | +**Tags**: [beginner](./level/beginner), [JavaScript](./theme/javascript), [Debugging](./theme/debugging), [Performance](./theme/performance) | 
|  | 12801 | +
 | 
|  | 12802 | +
 | 
|  | 12803 | +
 | 
|  | 12804 | +--- | 
|  | 12805 | +
 | 
|  | 12806 | +### How to measure performance in JavaScript? | 
|  | 12807 | +
 | 
|  | 12808 | +Use tools like `console.time()`, `performance.now()`, and Chrome DevTools Performance tab to analyze execution time. | 
|  | 12809 | +
 | 
|  | 12810 | +**Tags**: [beginner](./level/beginner), [JavaScript](./theme/javascript), [Performance](./theme/performance), [Optimization](./theme/optimization) | 
|  | 12811 | +
 | 
|  | 12812 | +
 | 
|  | 12813 | +
 | 
|  | 12814 | +--- | 
|  | 12815 | +
 | 
|  | 12816 | +### How to use Chrome DevTools for performance debugging? | 
|  | 12817 | +
 | 
|  | 12818 | +Use the Performance tab to record and analyze JavaScript execution, rendering, and paint times. | 
|  | 12819 | +
 | 
|  | 12820 | +**Tags**: [intermediate](./level/intermediate), [JavaScript](./theme/javascript), [Debugging](./theme/debugging), [DevTools](./theme/devtools) | 
|  | 12821 | +
 | 
|  | 12822 | +
 | 
|  | 12823 | +
 | 
|  | 12824 | +--- | 
|  | 12825 | +
 | 
|  | 12826 | +### What causes memory leaks in JavaScript? | 
|  | 12827 | +
 | 
|  | 12828 | +Memory leaks occur due to circular references, forgotten timers, event listeners, and global variables. | 
|  | 12829 | +
 | 
|  | 12830 | +**Tags**: [intermediate](./level/intermediate), [JavaScript](./theme/javascript), [Memory Management](./theme/memory_management), [Debugging](./theme/debugging) | 
|  | 12831 | +
 | 
|  | 12832 | +
 | 
|  | 12833 | +
 | 
|  | 12834 | +--- | 
|  | 12835 | +
 | 
|  | 12836 | +### How to detect memory leaks in JavaScript? | 
|  | 12837 | +
 | 
|  | 12838 | +Use Chrome DevTools' Memory tab to analyze heap snapshots and track memory usage over time. | 
|  | 12839 | +
 | 
|  | 12840 | +**Tags**: [advanced](./level/advanced), [JavaScript](./theme/javascript), [Debugging](./theme/debugging), [Performance](./theme/performance) | 
|  | 12841 | +
 | 
|  | 12842 | +
 | 
|  | 12843 | +
 | 
|  | 12844 | +--- | 
|  | 12845 | +
 | 
|  | 12846 | +### How to fix memory leaks in JavaScript? | 
|  | 12847 | +
 | 
|  | 12848 | +Remove unused event listeners, clear timers, use weak references, and avoid global variable accumulation. | 
|  | 12849 | +
 | 
|  | 12850 | +**Tags**: [advanced](./level/advanced), [JavaScript](./theme/javascript), [Optimization](./theme/optimization), [Debugging](./theme/debugging) | 
|  | 12851 | +
 | 
|  | 12852 | +
 | 
|  | 12853 | +
 | 
|  | 12854 | +--- | 
|  | 12855 | +
 | 
|  | 12856 | +### How to optimize DOM manipulation? | 
|  | 12857 | +
 | 
|  | 12858 | +Minimize reflows and repaints by batching updates, using document fragments, and avoiding direct style modifications. | 
|  | 12859 | +
 | 
|  | 12860 | +**Tags**: [intermediate](./level/intermediate), [JavaScript](./theme/javascript), [Performance](./theme/performance), [DOM](./theme/dom) | 
|  | 12861 | +
 | 
|  | 12862 | +
 | 
|  | 12863 | +
 | 
|  | 12864 | +--- | 
|  | 12865 | +
 | 
|  | 12866 | +### Why is JavaScript single-threaded? | 
|  | 12867 | +
 | 
|  | 12868 | +JavaScript runs on a single thread to simplify concurrency, using the event loop and asynchronous callbacks to handle tasks. | 
|  | 12869 | +
 | 
|  | 12870 | +**Tags**: [beginner](./level/beginner), [JavaScript](./theme/javascript), [Event Loop](./theme/event_loop), [Performance](./theme/performance) | 
|  | 12871 | +
 | 
|  | 12872 | +
 | 
|  | 12873 | +
 | 
|  | 12874 | +--- | 
|  | 12875 | +
 | 
|  | 12876 | +### How to use requestAnimationFrame() for performance? | 
|  | 12877 | +
 | 
|  | 12878 | +Use `requestAnimationFrame()` instead of `setTimeout()` for smoother animations synchronized with the browser's refresh rate. | 
|  | 12879 | +
 | 
|  | 12880 | +**Tags**: [intermediate](./level/intermediate), [JavaScript](./theme/javascript), [Animation](./theme/animation), [Optimization](./theme/optimization) | 
|  | 12881 | +
 | 
|  | 12882 | +
 | 
|  | 12883 | +
 | 
|  | 12884 | +--- | 
|  | 12885 | +
 | 
|  | 12886 | +### How to debounce and throttle functions? | 
|  | 12887 | +
 | 
|  | 12888 | +Debouncing limits how often a function runs, while throttling ensures a function executes at a fixed interval to improve performance. | 
|  | 12889 | +
 | 
|  | 12890 | +**Tags**: [intermediate](./level/intermediate), [JavaScript](./theme/javascript), [Optimization](./theme/optimization), [Performance](./theme/performance) | 
|  | 12891 | +
 | 
|  | 12892 | +
 | 
|  | 12893 | +
 | 
|  | 12894 | +--- | 
|  | 12895 | +
 | 
|  | 12896 | +### How to optimize loops in JavaScript? | 
|  | 12897 | +
 | 
|  | 12898 | +Use `forEach()` for readability, `for` loops for speed, and minimize redundant calculations inside loops. | 
|  | 12899 | +
 | 
|  | 12900 | +**Tags**: [intermediate](./level/intermediate), [JavaScript](./theme/javascript), [Performance](./theme/performance), [Optimization](./theme/optimization) | 
|  | 12901 | +
 | 
|  | 12902 | +
 | 
|  | 12903 | +
 | 
|  | 12904 | +--- | 
|  | 12905 | +
 | 
|  | 12906 | +### How do Web Workers improve performance? | 
|  | 12907 | +
 | 
|  | 12908 | +Web Workers allow running scripts in background threads, offloading CPU-heavy tasks from the main thread. | 
|  | 12909 | +
 | 
|  | 12910 | +**Tags**: [advanced](./level/advanced), [JavaScript](./theme/javascript), [Multithreading](./theme/multithreading), [Performance](./theme/performance) | 
|  | 12911 | +
 | 
|  | 12912 | +
 | 
|  | 12913 | +
 | 
|  | 12914 | +--- | 
|  | 12915 | +
 | 
|  | 12916 | +### How to optimize images for better performance? | 
|  | 12917 | +
 | 
|  | 12918 | +Use modern formats (WebP, AVIF), lazy loading, and responsive images to reduce load time. | 
|  | 12919 | +
 | 
|  | 12920 | +**Tags**: [beginner](./level/beginner), [JavaScript](./theme/javascript), [Optimization](./theme/optimization), [Performance](./theme/performance) | 
|  | 12921 | +
 | 
|  | 12922 | +
 | 
|  | 12923 | +
 | 
|  | 12924 | +--- | 
|  | 12925 | +
 | 
|  | 12926 | +### What is the impact of event bubbling on performance? | 
|  | 12927 | +
 | 
|  | 12928 | +Excessive event listeners can slow down performance. Use event delegation to minimize listeners. | 
|  | 12929 | +
 | 
|  | 12930 | +**Tags**: [advanced](./level/advanced), [JavaScript](./theme/javascript), [Event Handling](./theme/event_handling), [Performance](./theme/performance) | 
|  | 12931 | +
 | 
|  | 12932 | +
 | 
|  | 12933 | +
 | 
|  | 12934 | +--- | 
|  | 12935 | +
 | 
|  | 12936 | +### How to lazy load content in JavaScript? | 
|  | 12937 | +
 | 
|  | 12938 | +Use the Intersection Observer API to load images and components only when they enter the viewport. | 
|  | 12939 | +
 | 
|  | 12940 | +**Tags**: [intermediate](./level/intermediate), [JavaScript](./theme/javascript), [Performance](./theme/performance), [Optimization](./theme/optimization) | 
|  | 12941 | +
 | 
|  | 12942 | +
 | 
|  | 12943 | +
 | 
|  | 12944 | +--- | 
|  | 12945 | +
 | 
|  | 12946 | +### How does the event loop affect performance? | 
|  | 12947 | +
 | 
|  | 12948 | +Blocking operations delay execution. Optimize async tasks and avoid long synchronous code. | 
|  | 12949 | +
 | 
|  | 12950 | +**Tags**: [advanced](./level/advanced), [JavaScript](./theme/javascript), [Async](./theme/async), [Performance](./theme/performance) | 
|  | 12951 | +
 | 
|  | 12952 | +
 | 
|  | 12953 | +
 | 
|  | 12954 | +--- | 
|  | 12955 | +
 | 
|  | 12956 | +### How to reduce render-blocking resources? | 
|  | 12957 | +
 | 
|  | 12958 | +Defer JavaScript execution, use async scripts, and minimize CSS blocking resources. | 
|  | 12959 | +
 | 
|  | 12960 | +**Tags**: [advanced](./level/advanced), [JavaScript](./theme/javascript), [Performance](./theme/performance), [Optimization](./theme/optimization) | 
|  | 12961 | +
 | 
|  | 12962 | +
 | 
|  | 12963 | +
 | 
|  | 12964 | +--- | 
|  | 12965 | +
 | 
|  | 12966 | +### How to use the Performance API? | 
|  | 12967 | +
 | 
|  | 12968 | +The Performance API provides precise timing data, including `performance.now()` and `performance.mark()` for measuring execution time. | 
|  | 12969 | +
 | 
|  | 12970 | +**Tags**: [advanced](./level/advanced), [JavaScript](./theme/javascript), [Performance](./theme/performance), [Debugging](./theme/debugging) | 
|  | 12971 | +
 | 
|  | 12972 | +
 | 
|  | 12973 | +
 | 
|  | 12974 | +--- | 
|  | 12975 | +
 | 
|  | 12976 | +### What is the impact of long tasks on performance? | 
|  | 12977 | +
 | 
|  | 12978 | +Long tasks (>50ms) block the main thread, causing UI lag. Split tasks into smaller chunks with `setTimeout()` or `requestIdleCallback()`. | 
|  | 12979 | +
 | 
|  | 12980 | +**Tags**: [intermediate](./level/intermediate), [JavaScript](./theme/javascript), [Performance](./theme/performance), [Optimization](./theme/optimization) | 
|  | 12981 | +
 | 
|  | 12982 | +
 | 
|  | 12983 | +
 | 
| 12687 | 12984 | --- | 
|  | 
0 commit comments