Skip to content

Commit dfc67c5

Browse files
committed
qns: add JavaScript self-check exercises
Add manifest-ordered exercises across all 193 questions so learners can reinforce each answer with targeted prediction, classification, and explanation tasks. Keep definitions source-backed with English locale fallback, and document the adaptive concept-based authoring rules used to avoid filler.
1 parent 76326b6 commit dfc67c5

423 files changed

Lines changed: 8715 additions & 0 deletions

File tree

  • questions
    • can-you-offer-a-use-case-for-the-new-arrow-function-syntax-how-does-this-new-syntax-differ-from-other-functions/exercises
    • describe-event-bubbling/exercises
    • describe-event-capturing/exercises
    • describe-the-difference-between-script-async-and-script-defer/exercises
    • difference-between-document-load-event-and-document-domcontentloaded-event/exercises
    • difference-between-function-person-var-person-person-and-var-person-new-person/exercises
    • explain-ajax-in-as-much-detail-as-possible/exercises
    • explain-event-delegation/exercises
    • explain-function-prototype-bind/exercises
    • explain-hoisting/exercises
    • explain-how-jsonp-works-and-how-its-not-really-ajax/exercises
    • explain-how-prototypal-inheritance-works/exercises
    • explain-how-this-works-in-javascript/exercises
    • explain-the-concept-of-a-callback-function-in-asynchronous-operations/exercises
    • explain-the-concept-of-a-microtask-queue/exercises
    • explain-the-concept-of-caching-and-how-it-can-be-used-to-improve-performance/exercises
    • explain-the-concept-of-code-coverage-and-how-it-can-be-used-to-assess-test-quality/exercises
    • explain-the-concept-of-content-security-policy-csp-and-how-it-enhances-security/exercises
    • explain-the-concept-of-cross-site-request-forgery-csrf-and-its-mitigation-techniques/exercises
    • explain-the-concept-of-debouncing-and-throttling/exercises
    • explain-the-concept-of-destructuring-assignment-for-objects-and-arrays/exercises
    • explain-the-concept-of-error-propagation-in-javascript/exercises
    • explain-the-concept-of-hoisting-with-regards-to-functions/exercises
    • explain-the-concept-of-inheritance-in-es2015-classes/exercises
    • explain-the-concept-of-input-validation-and-its-importance-in-security/exercises
    • explain-the-concept-of-lazy-loading-and-how-it-can-improve-performance/exercises
    • explain-the-concept-of-lexical-scoping/exercises
    • explain-the-concept-of-partial-application/exercises
    • explain-the-concept-of-scope-in-javascript/exercises
    • explain-the-concept-of-tagged-templates/exercises
    • explain-the-concept-of-test-driven-development-tdd/exercises
    • explain-the-concept-of-the-prototype-pattern/exercises
    • explain-the-concept-of-the-singleton-pattern/exercises
    • explain-the-concept-of-the-spread-operator-and-its-uses/exercises
    • explain-the-concept-of-the-strategy-pattern/exercises
    • explain-the-concept-of-the-web-socket-api/exercises
    • explain-the-concept-of-this-binding-in-event-handlers/exercises
    • explain-the-concept-of-tree-shaking-in-module-bundling/exercises
    • explain-the-difference-between-classical-inheritance-and-prototypal-inheritance/exercises
    • explain-the-difference-between-documentqueryselector-and-documentgetelementbyid/exercises
    • explain-the-difference-between-dot-notation-and-bracket-notation-for-accessing-object-properties/exercises
    • explain-the-difference-between-global-scope-function-scope-and-block-scope/exercises
    • explain-the-difference-between-mutable-and-immutable-objects/exercises
    • explain-the-difference-between-shallow-copy-and-deep-copy/exercises
    • explain-the-difference-between-synchronous-and-asynchronous-functions/exercises
    • explain-the-difference-between-unit-testing-integration-testing-and-end-to-end-testing/exercises
    • explain-the-difference-in-hoisting-between-var-let-and-const/exercises
    • explain-the-differences-between-commonjs-modules-and-es-modules/exercises
    • explain-the-differences-on-the-usage-of-foo-between-function-foo-and-var-foo-function/exercises
    • explain-the-different-states-of-a-promise/exercises
    • explain-the-different-ways-the-this-keyword-can-be-bound/exercises
    • explain-the-event-phases-in-a-browser/exercises
    • explain-the-observer-pattern-and-its-use-cases/exercises
    • explain-the-same-origin-policy-with-regards-to-javascript/exercises
    • explain-what-a-single-page-app-is-and-how-to-make-one-seo-friendly/exercises
    • explain-why-the-following-doesnt-work-as-an-iife-function-foo--what-needs-to-be-changed-to-properly-make-it-an-iife/exercises
    • how-can-closures-be-used-to-create-private-variables/exercises
    • how-can-you-create-custom-error-objects/exercises
    • how-can-you-implement-secure-authentication-and-authorization-in-javascript-applications/exercises
    • how-can-you-optimize-dom-manipulation-for-better-performance/exercises
    • how-can-you-optimize-network-requests-for-better-performance/exercises
    • how-can-you-prevent-clickjacking-attacks/exercises
    • how-can-you-prevent-sql-injection-vulnerabilities-in-javascript-applications/exercises
    • how-can-you-share-code-between-files/exercises
    • how-can-you-test-asynchronous-code-in-javascript/exercises
    • how-do-currying-and-partial-application-differ-from-each-other/exercises
    • how-do-iframe-on-a-page-communicate/exercises
    • how-do-sets-and-maps-handle-equality-checks-for-objects/exercises
    • how-do-you-abort-a-web-request-using-abortcontrollers/exercises
    • how-do-you-access-the-index-of-an-element-in-an-array-during-iteration/exercises
    • how-do-you-add-remove-and-modify-html-elements-using-javascript/exercises
    • how-do-you-add-remove-and-update-elements-in-an-array/exercises
    • how-do-you-check-if-an-object-has-a-specific-property/exercises
    • how-do-you-check-the-data-type-of-a-variable/exercises
    • how-do-you-convert-a-set-to-an-array-in-javascript/exercises
    • how-do-you-convert-a-string-to-a-number-in-javascript/exercises
    • how-do-you-create-a-constructor-function/exercises
    • how-do-you-detect-if-javascript-is-disabled-on-a-page/exercises
    • how-do-you-get-the-query-string-values-of-the-current-page-in-javascript/exercises
    • how-do-you-handle-errors-in-asynchronous-operations/exercises
    • how-do-you-handle-errors-using-trycatch-blocks/exercises
    • how-do-you-import-and-export-modules-in-javascript/exercises
    • how-do-you-make-an-http-request-using-the-fetch-api/exercises
    • how-do-you-manipulate-css-styles-using-javascript/exercises
    • how-do-you-organize-your-code-module-pattern-classical-inheritance/exercises
    • how-do-you-prevent-the-default-behavior-of-an-event/exercises
    • how-do-you-redirect-to-a-new-page-in-javascript/exercises
    • how-do-you-reliably-determine-whether-an-object-is-empty/exercises
    • how-do-you-use-windowhistory-api/exercises
    • how-do-you-validate-form-elements-using-the-constraint-validation-api/exercises
    • how-do-you-write-unit-tests-for-javascript-code/exercises
    • how-does-hoisting-affect-function-declarations-and-expressions/exercises
    • how-does-javascript-garbage-collection-work/exercises
    • how-is-promiseall-different-from-promiseallsettled/exercises
    • provide-some-examples-of-how-currying-and-partial-application-can-be-used/exercises
    • what-advantage-is-there-for-using-the-arrow-syntax-for-a-method-in-a-constructor/exercises
    • what-are-callback-functions-and-how-are-they-used/exercises
    • what-are-default-parameters-and-how-are-they-used/exercises
    • what-are-design-patterns-and-why-are-they-useful/exercises
    • what-are-event-listeners-and-how-are-they-used/exercises
    • what-are-iterators-and-generators-and-what-are-they-used-for/exercises
    • what-are-javascript-object-getters-and-setters-for/exercises
    • what-are-javascript-object-property-flags-and-descriptors/exercises
    • what-are-javascript-polyfills-for/exercises
    • what-are-mocks-and-stubs-and-how-are-they-used-in-testing/exercises
    • what-are-modules-and-why-are-they-useful/exercises
    • what-are-progressive-web-applications-pwas/exercises
    • what-are-promises-and-how-do-they-work/exercises
    • what-are-proxies-in-javascript-used-for/exercises
    • what-are-rest-parameters-and-how-are-they-used/exercises
    • what-are-server-sent-events/exercises
    • what-are-sets-and-maps-and-how-are-they-used/exercises
    • what-are-some-best-practices-for-handling-sensitive-data-in-javascript/exercises
    • what-are-some-best-practices-for-writing-maintainable-and-effective-tests/exercises
    • what-are-some-common-performance-bottlenecks-in-javascript-applications/exercises
    • what-are-some-common-security-headers-and-their-purpose/exercises
    • what-are-some-of-the-advantages-disadvantages-of-writing-javascript-code-in-a-language-that-compiles-to-javascript/exercises
    • what-are-some-techniques-for-reducing-reflows-and-repaints/exercises
    • what-are-some-tools-and-techniques-for-identifying-security-vulnerabilities-in-javascript-code/exercises
    • what-are-some-tools-that-can-be-used-for-javascript-testing/exercises
    • what-are-some-tools-that-can-be-used-to-measure-and-analyze-javascript-performance/exercises
    • what-are-symbols-used-for/exercises
    • what-are-template-literals-and-how-are-they-used/exercises
    • what-are-the-advantages-and-disadvantages-of-using-ajax/exercises
    • what-are-the-advantages-of-using-the-spread-operator-with-arrays-and-objects/exercises
    • what-are-the-benefits-of-using-a-module-bundler/exercises
    • what-are-the-benefits-of-using-currying-and-partial-application/exercises
    • what-are-the-benefits-of-using-spread-syntax-and-how-is-it-different-from-rest-syntax/exercises
    • what-are-the-common-pitfalls-of-using-the-this-keyword/exercises
    • what-are-the-differences-between-es6-class-and-es5-function-constructors/exercises
    • what-are-the-differences-between-map-set-and-weakmap-weakset/exercises
    • what-are-the-differences-between-variables-created-using-let-var-or-const/exercises
    • what-are-the-differences-between-xmlhttprequest-and-fetch/exercises
    • what-are-the-different-methods-for-iterating-over-an-array/exercises
    • what-are-the-different-types-of-errors-in-javascript/exercises
    • what-are-the-different-types-of-testing-in-software-development/exercises
    • what-are-the-different-ways-to-copy-an-object-or-an-array/exercises
    • what-are-the-different-ways-to-make-an-api-call-in-javascript/exercises
    • what-are-the-metadata-fields-of-a-module/exercises
    • what-are-the-potential-issues-caused-by-hoisting/exercises
    • what-are-the-potential-pitfalls-of-using-closures/exercises
    • what-are-the-pros-and-cons-of-using-promises-instead-of-callbacks/exercises
    • what-are-the-various-data-types-in-javascript/exercises
    • what-are-the-various-ways-to-create-objects-in-javascript/exercises
    • what-are-web-workers-and-how-can-they-be-used-to-improve-performance/exercises
    • what-are-workers-in-javascript-used-for/exercises
    • what-do-you-think-of-amd-vs-commonjs/exercises
    • what-is-a-closure-and-how-why-would-you-use-one/exercises
    • what-is-asyncawait-and-how-does-it-simplify-asynchronous-code/exercises
    • what-is-cross-site-scripting-xss-and-how-can-you-prevent-it/exercises
    • what-is-currying-and-how-does-it-work/exercises
    • what-is-event-loop-what-is-the-difference-between-call-stack-and-task-queue/exercises
    • what-is-objectfreeze-for/exercises
    • what-is-objectpreventextensions-for/exercises
    • what-is-objectseal-for/exercises
    • what-is-recursion-and-how-is-it-used-in-javascript/exercises
    • what-is-the-command-pattern-and-how-is-it-used/exercises
    • what-is-the-decorator-pattern-and-how-is-it-used/exercises
    • what-is-the-definition-of-a-higher-order-function/exercises
    • what-is-the-difference-between-a-map-object-and-a-plain-object-in-javascript/exercises
    • what-is-the-difference-between-a-parameter-and-an-argument/exercises
    • what-is-the-difference-between-double-equal-and-triple-equal/exercises
    • what-is-the-difference-between-eventpreventdefault-and-eventstoppropagation/exercises
    • what-is-the-difference-between-innerhtml-and-textcontent/exercises
    • what-is-the-difference-between-mouseenter-and-mouseover-event/exercises
    • what-is-the-difference-between-settimeout-setimmediate-and-processnexttick/exercises
    • what-is-the-difference-between-the-window-object-and-the-document-object/exercises
    • what-is-the-dom-and-how-is-it-structured/exercises
    • what-is-the-factory-pattern-and-how-is-it-used/exercises
    • what-is-the-intl-namespace-object-for/exercises
    • what-is-the-module-pattern-and-how-does-it-help-with-encapsulation/exercises
    • what-is-the-prototype-chain-and-how-does-it-work/exercises
    • what-is-the-purpose-of-the-break-and-continue-statements/exercises
    • what-is-the-purpose-of-the-finally-block/exercises
    • what-is-the-purpose-of-the-new-keyword/exercises
    • what-is-the-purpose-of-the-switch-statement/exercises
    • what-is-the-spread-operator-and-how-is-it-used/exercises
    • what-is-the-ternary-operator-and-how-is-it-used/exercises
    • what-is-the-use-of-promiseall/exercises
    • what-is-use-strict-what-are-the-advantages-and-disadvantages-to-using-it/exercises
    • what-language-constructs-do-you-use-for-iterating-over-object-properties-and-array-items/exercises
    • what-tools-and-techniques-do-you-use-for-debugging-javascript-code/exercises
    • whats-a-typical-use-case-for-anonymous-functions/exercises
    • whats-the-difference-between-a-variable-that-is-null-undefined-or-undeclared-how-would-you-go-about-checking-for-any-of-these-states/exercises
    • whats-the-difference-between-an-attribute-and-a-property/exercises
    • whats-the-difference-between-call-and-apply/exercises
    • when-would-you-use-document-write/exercises
    • why-is-extending-built-in-javascript-objects-not-a-good-idea/exercises
    • why-is-it-in-general-a-good-idea-to-leave-the-global-scope-of-a-website-as-is-and-never-touch-it/exercises
    • why-you-might-want-to-create-static-class-members/exercises

Some content is hidden

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

‎AGENTS.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ questions/<slug>/
103103
en-US.mdx
104104
<locale>.mdx (localized content, when available)
105105
en-US.langnostic.json (generated translation state, when available)
106+
exercises/index.json (when exercises are present)
107+
exercises/<exercise-id>/en-US.mdx
106108
```
107109

108110
- Treat `en-US.mdx` as the source locale.
@@ -114,6 +116,14 @@ questions/<slug>/
114116
- Do not treat `published: true` as permission to leave incomplete or placeholder content.
115117
- Do not edit generated question content in `README.md` directly. Edit the source question and regenerate the README.
116118

119+
### Exercises
120+
121+
- Keep exercises outside the answer MDX. Store each definition in `exercises/<exercise-id>/en-US.mdx` and list all IDs once, in learner order, in `exercises/index.json`. Do not add `<Exercise>` markers or an exercises heading to localized answer articles; GreatFrontEnd renders the manifest after the answer.
122+
- Map the important, transferable concepts before choosing a count. Start with one exercise per concept and add a second only when it uses a materially different scenario and reasoning task, provides evidence the first cannot, and keeps the complete sequence within 1–3 exercises.
123+
- Use `single-select` for one deterministic answer, `multi-select` for several independently evaluable claims with at least two correct answers, and `self-review` for bounded explanation, comparison, or tradeoff reasoning. Order the sequence from foundational understanding to application or failure mode, with self-review last.
124+
- Give every exercise a stable kebab-case ID and one primary learning objective. Keep prompts context-complete and prefer new traces, consequences, or implementation decisions over recall of nearby wording.
125+
- Every exercise requires an English definition. Localized definitions are optional and fall back to English; do not create translations unless they are explicitly in scope.
126+
117127
### Answer structure
118128

119129
Every `en-US.mdx` answer should use this outer structure:
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
type: multi-select
3+
---
4+
5+
Which statements distinguish arrow functions from ordinary functions? Select all that apply.
6+
7+
## Options
8+
9+
### lexical-this (correct)
10+
11+
An arrow resolves `this` from its enclosing lexical scope.
12+
13+
> Arrows do not create their own `this` binding based on how they are invoked.
14+
15+
### direct-object-method
16+
17+
An arrow assigned directly as an object property receives that object as `this` when called as a method.
18+
19+
> The property-call receiver does not bind an arrow; it continues to use `this` from the surrounding scope where it was created.
20+
21+
### lexical-arguments (correct)
22+
23+
An arrow has no own `arguments` object and resolves `arguments` from an enclosing non-arrow function when available.
24+
25+
> Ordinary functions create their own `arguments` binding, while arrows capture the surrounding one.
26+
27+
### constructor-with-prototype
28+
29+
An arrow can be called with `new` and provides a `prototype` for its instances.
30+
31+
> Arrows are not constructors, calling one with `new` throws `TypeError`, and they do not have a `prototype` property.
32+
33+
### implicit-expression-return (correct)
34+
35+
An arrow with an expression body can return that expression without a `return` statement.
36+
37+
> The concise body form provides an implicit return; ordinary function bodies require an explicit `return` for the same value.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"ids": ["trace-arrow-this-capture", "classify-arrow-function-differences"]
3+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
type: single-select
3+
---
4+
5+
What does this code log?
6+
7+
```js
8+
const counter = {
9+
value: 1,
10+
makeIncrementer() {
11+
return () => ++this.value;
12+
},
13+
};
14+
15+
const increment = counter.makeIncrementer();
16+
const other = { value: 10 };
17+
18+
console.log(increment.call(other), counter.value, other.value);
19+
```
20+
21+
## Options
22+
23+
### two-two-ten (correct)
24+
25+
`2 2 10`
26+
27+
> The arrow captures `this` from the `counter.makeIncrementer()` call, and `call(other)` cannot replace that lexical binding.
28+
29+
### eleven-one-eleven
30+
31+
`11 1 11`
32+
33+
> That would require `call(other)` to rebind the arrow's `this`, but arrows do not receive `this` from their invocation form.
34+
35+
### two-one-ten
36+
37+
`2 1 10`
38+
39+
> Incrementing `this.value` mutates the captured `counter` object, so its value becomes `2`.
40+
41+
### type-error
42+
43+
It throws `TypeError` because arrow functions cannot be used with `call`.
44+
45+
> An arrow can be invoked through `call`; the supplied receiver is simply ignored for its lexical `this` resolution.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
type: multi-select
3+
---
4+
5+
Which statements about a bubbling click event are correct? Select all that apply.
6+
7+
## Options
8+
9+
### target-stays-origin (correct)
10+
11+
`event.target` continues to identify the deepest element where the event originated as ancestor listeners run.
12+
13+
> `target` describes the origin of the dispatch, not the listener currently handling it.
14+
15+
### current-target-changes (correct)
16+
17+
`event.currentTarget` identifies the element whose listener is currently executing.
18+
19+
> Each listener observes its own registered element through `currentTarget`.
20+
21+
### prevent-default-stops-bubbling
22+
23+
`event.preventDefault()` prevents the event from reaching ancestor listeners.
24+
25+
> `preventDefault()` cancels a default browser action; `stopPropagation()` controls propagation.
26+
27+
### stop-propagation-blocks-ancestors (correct)
28+
29+
Calling `event.stopPropagation()` at the target prevents later ancestor listeners on the event path from running.
30+
31+
> Stopping propagation prevents the event from continuing along the remaining propagation path.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"ids": ["trace-bubbling-listener-order", "classify-bubbling-controls"]
3+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
type: single-select
3+
---
4+
5+
A user clicks the `button`. What does this code log?
6+
7+
```js
8+
const outer = document.querySelector('#outer');
9+
const button = document.querySelector('button');
10+
11+
outer.addEventListener('click', () => console.log('outer'));
12+
button.addEventListener('click', () => console.log('button'));
13+
document.body.addEventListener('click', () => console.log('body'));
14+
```
15+
16+
## Options
17+
18+
### button-outer-body (correct)
19+
20+
`button`, then `outer`, then `body`
21+
22+
> The event reaches its target and then bubbles through ancestors from the nearest ancestor outward.
23+
24+
### body-outer-button
25+
26+
`body`, then `outer`, then `button`
27+
28+
> That is ancestor-to-target order; these listeners use the default bubbling phase rather than capture.
29+
30+
### button-only
31+
32+
`button` only
33+
34+
> A click bubbles by default, so ancestor bubble listeners also receive it unless propagation is stopped.
35+
36+
### outer-body-button
37+
38+
`outer`, then `body`, then `button`
39+
40+
> The target listener runs before ancestor listeners during the bubbling phase.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"ids": ["trace-capture-and-bubble-order"]
3+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
type: single-select
3+
---
4+
5+
A `button` is inside a `section`. What is logged when the button is clicked?
6+
7+
```js
8+
section.addEventListener('click', () => console.log('section bubble'));
9+
section.addEventListener('click', () => console.log('section capture'), {
10+
capture: true,
11+
});
12+
button.addEventListener('click', () => console.log('button'));
13+
```
14+
15+
## Options
16+
17+
### capture-button-bubble (correct)
18+
19+
`section capture`, `button`, `section bubble`
20+
21+
> Capture listeners run on the way toward the target, followed by target handling and then ancestor bubble listeners.
22+
23+
### button-capture-bubble
24+
25+
`button`, `section capture`, `section bubble`
26+
27+
> The section capture listener runs before the event reaches the target button.
28+
29+
### bubble-button-capture
30+
31+
`section bubble`, `button`, `section capture`
32+
33+
> A bubble listener cannot run before target handling, and capture precedes both.
34+
35+
### capture-bubble-button
36+
37+
`section capture`, `section bubble`, `button`
38+
39+
> After capture reaches the target, the target listener runs before bubbling returns to the section.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
type: single-select
3+
---
4+
5+
A checkout draft should survive reloads in the current tab, remain isolated from another tab on the same origin, and disappear when the tab closes. Which storage mechanism best matches those requirements?
6+
7+
## Options
8+
9+
### session-storage (correct)
10+
11+
`sessionStorage`
12+
13+
> `sessionStorage` is scoped to an origin and a page session, survives reloads, and is normally cleared when that tab closes.
14+
15+
### local-storage
16+
17+
`localStorage`
18+
19+
> `localStorage` persists until cleared and is shared with other same-origin tabs, so it violates both isolation and lifetime requirements.
20+
21+
### persistent-cookie
22+
23+
A persistent cookie
24+
25+
> A persistent cookie can outlive the tab and is sent with matching requests, neither of which is needed here.
26+
27+
### session-cookie
28+
29+
A session cookie
30+
31+
> A session cookie is browser-session scoped rather than reliably isolated to one tab.

0 commit comments

Comments
 (0)