Rédigé par des étudiants ayant réussi Disponible immédiatement après paiement Lire en ligne ou en PDF Mauvais document ? Échangez-le gratuitement 4,6 TrustPilot
logo-home
Document preview thumbnail
Aperçu 4 sur 31 pages
Examen

ITSW 3151 D280 JavaScript Programming - Objective Assessment - WGU 2025.

Document preview thumbnail
Aperçu 4 sur 31 pages

ITSW 3151 D280 JavaScript Programming - Objective Assessment - WGU 2025.ITSW 3151 D280 JavaScript Programming - Objective Assessment - WGU 2025.ITSW 3151 D280 JavaScript Programming - Objective Assessment - WGU 2025.

Aperçu du contenu

D280 ITSW 3151 JavaScript
Programming

Objective Assessment Review

(Questions & Solutions)

2025




©2025

,1. Question 1
Consider the following code snippet that demonstrates a closure:
```javascript
function createIncrementer() {
let count = 0;
return function() {
count += 1;
return count;
};
}

const inc1 = createIncrementer();
console.log(inc1()); // ?
console.log(inc1()); // ?
```
What is the expected output of the two `console.log` statements?
- A. 0 and 0
- B. 1 and 2
- C. 1 and 1
- D. 2 and 3
ANS: B
Rationale: The inner function forms a closure over the variable
`count`. Each time `inc1()` is invoked, it increments `count` from its
previous value (starting at 0), so the outputs are 1 and then 2.

2. Question 2
In advanced JavaScript, when using an arrow function within an object
method, what is a key difference compared to traditional function
expressions?
- A. Arrow functions bind `this` lexically.
- B. Arrow functions create a new `this` context.
- C. Arrow functions are always anonymous.
©2025

, - D. Arrow functions cannot be assigned to variables.
ANS: A
Rationale: Arrow functions do not have their own `this` binding;
instead, they inherit the `this` value from the surrounding (lexical) scope,
which is crucial in many advanced patterns.

3. Question 3
Which of the following best describes the behavior of JavaScript’s event
loop when processing asynchronous operations?
- A. It processes all macrotasks first, then microtasks.
- B. It handles the microtask queue before processing the next
macrotask.
- C. It executes asynchronous callbacks immediately as they are
encountered.
- D. It blocks execution until all asynchronous tasks complete.
ANS: B
Rationale: The event loop empties the call stack, then processes the
microtask queue (including promise resolutions) before moving on to the
next macrotask, ensuring timely and ordered execution.

4. Question 4
Examine the following Promise chain:
```javascript
Promise.resolve(42)
.then(x => { console.log(x); return x + 1; })
.then(x => { throw new Error('fail'); })
.catch(e => { console.log(e.message); return 100; })
.then(x => { console.log(x); });
```
What is the output produced by this code?
- A. 42, "fail", 43
- B. 42, "fail", 100
- C. 42, 100, "fail"
- D. 42, 43, "fail"
ANS: B
©2025

, Rationale: The first `.then` logs 42 and returns 43. The next `.then`
throws an error, triggering the `.catch`, which logs "fail" and returns 100.
The final `.then` then logs 100.

5. Question 5
Which JavaScript feature makes an object iterable using the `for...of`
loop?
- A. `Symbol.iterator`
- B. `Object.keys`
- C. `Array.prototype.forEach`
- D. `Proxy` traps
ANS: A
Rationale: Defining a method on an object with the key
`Symbol.iterator` allows that object to be iterated over using `for...of`.

6. Question 6
Regarding JavaScript’s prototype inheritance, which statement is
correct?
- A. Every function in JavaScript automatically receives a `prototype`
property used for inheritance.
- B. Prototype inheritance has been entirely replaced by ES6 classes.
- C. Only objects created with the `new` operator have prototypes.
- D. Prototypes exist solely for arrays.
ANS: A
Rationale: Every function has a `prototype` property, and the
prototype chain enables objects to inherit properties and methods from
one another.

7. Question 7
What is the main advantage of using `async/await` over traditional
promise chaining?
- A. It eliminates the need for error handling.
- B. It makes asynchronous code appear and behave much like
synchronous code, enhancing readability.
- C. It automatically executes asynchronous tasks in parallel.
©2025

Infos sur le Document

Publié le
28 mai 2025
Nombre de pages
31
Écrit en
2024/2025
Type
Examen
Contenu
Inconnu
$17.99

Mauvais document ? Échangez-le gratuitement Dans les 14 jours suivant votre achat et avant le téléchargement, vous pouvez choisir un autre document. Vous pouvez simplement dépenser le montant à nouveau.
Rédigé par des étudiants ayant réussi
Disponible immédiatement après paiement
Lire en ligne ou en PDF

Seller avatar
Les scores de réputation sont basés sur le nombre de documents qu'un vendeur a vendus contre paiement ainsi que sur les avis qu'il a reçu pour ces documents. Il y a trois niveaux: Bronze, Argent et Or. Plus la réputation est bonne, plus vous pouvez faire confiance sur la qualité du travail des vendeurs.
EmilioOchieng
4.1
(24)
Vendu
148
Abonnés
17
Éléments
4032
Dernière vente
3 mois de cela


Pourquoi les étudiants choisissent Stuvia

Créé par d'autres étudiants, vérifié par les avis

Une qualité sur laquelle compter : rédigé par des étudiants qui ont réussi et évalué par d'autres qui ont utilisé ce document.

Le document ne convient pas ? Choisis un autre document

Aucun souci ! Tu peux sélectionner directement un autre document qui correspond mieux à ce que tu cherches.

Paye comme tu veux, apprends aussitôt

Aucun abonnement, aucun engagement. Paye selon tes habitudes par carte de crédit et télécharge ton document PDF instantanément.

Student with book image

“Acheté, téléchargé et réussi. C'est aussi simple que ça.”

Alisha Student

Vous travaillez sur vos références ?

Créez des citations précises en APA, MLA et Harvard avec notre générateur de sources gratuit.

Vous travaillez sur vos références ?

Foire aux questions