Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Document preview thumbnail
Preview 4 out of 31 pages
Exam (elaborations)

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

Document preview thumbnail
Preview 4 out of 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.

Content preview

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

Document information

Uploaded on
May 28, 2025
Number of pages
31
Written in
2024/2025
Type
Exam (elaborations)
Contains
Unknown
$17.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
EmilioOchieng
4.1
(24)
Sold
150
Followers
17
Items
4030
Last sold
1 week ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions