Limited-Time Offer: Enjoy 50% Savings! - Ends In 0d 00h 00m 00s Coupon code: 50OFF
Welcome to QA4Exam
Logo

- Trusted Worldwide Questions & Answers

Most Recent Salesforce JS-Dev-101 Exam Dumps

 

Prepare for the Salesforce Certified JavaScript Developer exam with our extensive collection of questions and answers. These practice Q&A are updated according to the latest syllabus, providing you with the tools needed to review and test your knowledge.

QA4Exam focus on the latest syllabus and exam objectives, our practice Q&A are designed to help you identify key topics and solidify your understanding. By focusing on the core curriculum, These Questions & Answers helps you cover all the essential topics, ensuring you're well-prepared for every section of the exam. Each question comes with a detailed explanation, offering valuable insights and helping you to learn from your mistakes. Whether you're looking to assess your progress or dive deeper into complex topics, our updated Q&A will provide the support you need to confidently approach the Salesforce JS-Dev-101 exam and achieve success.

The questions for JS-Dev-101 were last updated on Apr 21, 2026.
  • Viewing page 1 out of 30 pages.
  • Viewing questions 1-5 out of 149 questions
Get All 149 Questions & Answers
Question No. 1

Refer to the following array:

```javascript

let arr = [1, 2, 3, 4, 5];

```

Which two lines of code result in a second array, `arr2`, created such that `arr2` is a reference to

`arr`?

Choose 2 answers

Show Answer Hide Answer
Correct Answer: C, D

Question No. 2

A developer imports:

import printPrice from '/path/PricePrettyPrint.js';

What must be true about printPrice for this import to work?

Show Answer Hide Answer
Correct Answer: C

________________________________________

Comprehensive and Detailed Explanation From Exact Extract JavaScript Knowledge

The syntax:

import printPrice from 'module';

means the module must export its function as a default export:

export default function printPrice() { ... }

Why the others are wrong:

Named exports require curly braces:

import { printPrice } from 'module';

''all export'' and ''multi export'' are not JavaScript terms.

Therefore, printPrice must be the default export.

________________________________________

JavaScript Knowledge Reference (text-only)

Default imports use: import name from 'module'.

Named imports require braces: import { name } from 'module'.


Question No. 3

A developer has a fizzbuzz function that, when passed in a number, returns the following:

'fizz' if the number is divisible by 3.

'buzz' if the number is divisible by 5.

'fizzbuzz' if the number is divisible by both 3 and 5.

Empty string '' if the number is divisible by neither 3 nor 5.

Which two test cases properly test scenarios for the fizzbuzz function?

Show Answer Hide Answer
Correct Answer: A, D

Comprehensive and Detailed Explanation From Exact Extract JavaScript knowledge:

First, recall the fizzbuzz rules:

If n divisible by 3 and not by 5 return 'fizz'.

If n divisible by 5 and not by 3 return 'buzz'.

If n divisible by both 3 and 5 return 'fizzbuzz'.

Otherwise return '' (empty string).

Evaluate each test:

Option A:

let res = fizzbuzz(true);

console.assert(res === '');

In JavaScript, when using arithmetic operations with true, it is coerced to the number 1. A typical implementation of fizzbuzz would treat the argument as a number and compute:

true % 3 1 % 3 1

true % 5 1 % 5 1

So true is effectively treated as 1, which is divisible by neither 3 nor 5. The function should return ''. The assertion res === '' will pass.

This test covers the scenario ''neither divisible by 3 nor 5''.

Option B:

let res = fizzbuzz(3);

console.assert(res === '');

3 is divisible by 3 but not by 5.

According to fizzbuzz rules, fizzbuzz(3) should return 'fizz'.

This test expects '', so it is incorrect; the assertion would fail in a correct implementation.

Option C:

let res = fizzbuzz(5);

console.assert(res === 'fizz');

5 is divisible by 5 but not by 3.

According to fizzbuzz rules, fizzbuzz(5) should return 'buzz'.

This test expects 'fizz', so it is incorrect.

Option D:

let res = fizzbuzz(15);

console.assert(res === 'fizzbuzz');

15 is divisible by both 3 and 5.

According to fizzbuzz rules, fizzbuzz(15) should return 'fizzbuzz'.

This assertion correctly matches the expected result, so it is a proper test case.

Thus, the two test cases that correctly test valid fizzbuzz behavior are:

Study Guide / Concept Reference (no links):

Modulo operator (%) for divisibility checks

Truthy/number coercion of boolean true in arithmetic (Number(true) === 1)

Designing unit tests with console.assert

Typical fizzbuzz logic structure and expected outputs

________________________________________


Question No. 4

A developer wants to use a try...catch statement to catch any error that countSheep() may throw and pass it to a handleError() function.

What is the correct implementation of the try...catch?

Show Answer Hide Answer
Correct Answer: A

Comprehensive and Detailed

Errors thrown inside setTimeout callbacks occur asynchronously, in a different tick of the event loop. A try...catch around setTimeout itself (as in D) cannot catch errors thrown later in the scheduled callback.

To catch errors from countSheep() when it's called asynchronously, the try...catch must wrap the call inside the timeout callback:

setTimeout(function() {

try {

countSheep();

} catch (e) {

handleError(e);

}

}, 1000);

B uses finally incorrectly and references e out of scope.

C is not valid JavaScript syntax.

D's catch can only handle synchronous errors thrown before setTimeout returns, not those thrown inside the callback.

________________________________________


Question No. 5

Given the code below:

01 const delay = async delay => {

02 return new Promise((resolve, reject) => {

03 console.log(1);

04 setTimeout(resolve, delay);

05 });

06 };

07

08 const callDelay = async () => {

09 console.log(2);

10 const yup = await delay(1000);

11 console.log(3);

12 };

13

14 console.log(4);

15 callDelay();

16 console.log(5);

What is logged to the console?

Show Answer Hide Answer
Correct Answer: A

Comprehensive and Detailed Explanation From Exact Extract JavaScript Knowledge:

Execution order:

Top-level code runs synchronously:

Line 14: console.log(4); logs 4.

Line 15: callDelay(); is called.

Inside callDelay:

Line 9: console.log(2); logs 2.

Line 10: await delay(1000);:

Calls delay(1000).

Inside delay(1000):

Line 3: console.log(1); logs 1.

Line 4: setTimeout(resolve, delay); schedules resolve in 1000 ms.

delay returns a pending Promise. await pauses callDelay here and returns control to the event loop.

Back to top-level:

Line 16: console.log(5); logs 5.

So synchronous log sequence is: 4, 2, 1, 5.

After ~1000 ms:

The setTimeout in delay resolves the Promise.

The await in callDelay resumes.

Line 11: console.log(3); logs 3.

Final log order: 4 2 1 5 3.

Both A and B show the same sequence; one must be chosen, so A is correct.

Concepts: async/await flow, Promise resolution timing, event loop, and ordering of synchronous vs timer callbacks.

________________________________________


Unlock All Questions for Salesforce JS-Dev-101 Exam

Full Exam Access, Actual Exam Questions, Validated Answers, Anytime Anywhere, No Download Limits, No Practice Limits

Get All 149 Questions & Answers