From 96fe0a5439cc990fc0b28ba88ba6d86758a3b788 Mon Sep 17 00:00:00 2001 From: Arik Chakma Date: Sun, 24 Sep 2023 21:37:29 +0600 Subject: [PATCH] wip: add more questions --- src/data/question-groups/javascript/javascript.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/data/question-groups/javascript/javascript.md b/src/data/question-groups/javascript/javascript.md index c3fdebfc8..1b1766fc4 100644 --- a/src/data/question-groups/javascript/javascript.md +++ b/src/data/question-groups/javascript/javascript.md @@ -196,4 +196,14 @@ questions: topics: - 'Core' - 'Advanced' + - question: What is the difference between `Map` and `WeakMap` in JavaScript? + answer: The `Map` object holds key-value pairs and remembers the original insertion order of the keys. Whereas, the `WeakMap` object is a collection of key/value pairs in which the keys are weakly referenced. You can use any data type as a key or value in a `Map` whereas in `WeakMap` you can only use objects as keys. The `WeakMap` is not iterable whereas `Map` is. In `WeakMap` it holds the weak reference to the original object which means if there are no other references to an object stored in the `WeakMap`, those objects can be garbage collected. + topics: + - 'Core' + - 'Advanced' + - question: Garbage collection in JavaScript? + answer: The JavaScript engine uses automatic garbage collection. JavaScript automatically manages memory by freeing up space used by objects no longer needed. This algorithm is called Mark and Sweep, which is performed periodically by the JavaScript engine. + topics: + - 'Core' + - 'Advanced' ---