JS-Dev-101 Salesforce Certified JavaScript Developer I Practice Questions
Prepare for JS-Dev-101 with more than an answer.
- Exam fee
- $200 USD
- Time limit
- 105 minutes
- Passing score
- 65%
- Level
- Professional
- Valid for
- Requires annual maintenance modules on Trailhead
Domains covered on the exam 7
- Variables, Types, and Collections23%
- Objects, Functions, and Classes25%
- Browser and Events17%
- Debugging and Error Handling7%
- Asynchronous Programming13%
- Server Side JavaScript8%
- Testing7%
- 1
A developer wants to define a class
Managerthat extendsEmployee. Which code snippet correctly implements the constructor of theManagerclass?Show answer details
Correct answer: A
In a derived class,
super()must be called before accessingthis. This initializes the parent class's constructor. - 2
Consider the following code:
const obj = { value: 42, getValue: function() { return this.value; } }; const retrieve = obj.getValue; console.log(retrieve());What is the result when running this in strict mode, and why?
Show answer details
Correct answer: B
When
obj.getValueis assigned toretrieveand called as a standalone functionretrieve(), the context (this) is lost. In strict mode,thisisundefinedin a standalone function call, causing an error when accessingthis.value. - 3
A developer wants to create an object that inherits directly from
nullto ensure it has no prototype methods liketoStringorhasOwnProperty.Which command achieves this?
Show answer details
Correct answer: A
Object.create(null)creates a new object with its prototype set tonull. This is often used for dictionary-like objects where you don't want inherited properties interfering. - 4
Which of the following statements about Arrow Functions are true? (Select TWO)
Show answer details
Correct answer: A, D
Arrow functions do not provide the
argumentsobject. Rest parameters (...args) should be used instead.Arrow functions capture
thislexically from the surrounding scope, rather than having their own dynamicthis. - 5
You are implementing a module that needs to export a single main function as the primary export, but also provide a few utility functions.
Which pattern correctly implements this using ES6 modules?
Show answer details
Correct answer: A
ES6 modules allow one
defaultexport and multiple named exports in the same file. This allows consumers to import the main function easily (import main from ...) and destructure utilities if needed (import main, { util } from ...). - 6
A developer is building a financial dashboard that processes transaction lists. They need to calculate the total balance from an array of transaction objects, where each object contains a
type('credit' or 'debit') and anamount.Which array method and implementation best achieves this single-value result?
Show answer details
Correct answer: C
The
reduce()method is specifically designed to transform an array into a single value (the accumulator) by applying a function to each element.map()creates a new array of the same length, which is not the goal here. - 7
A developer encounters a bug where a variable declared inside a
forloop is accessible outside the loop, causing unexpected behavior in subsequent logic. The code uses thevarkeyword.Which explanation describes why this is happening?
Show answer details
Correct answer: C
The
varkeyword creates variables that are function-scoped (or globally scoped if outside a function). They ignore block boundaries likeifstatements orforloops. To restrict the variable to the loop block,letshould be used. - 8
A developer needs to create a unique list of user IDs from a raw array that contains duplicates. The final result must be an array.
Which approach provides the most concise and performant solution?
Show answer details
Correct answer: A
The
Setobject stores only unique values. Passing the array to theSetconstructor removes duplicates, and the spread syntax[...]converts it back to an array. This is more concise and generally more performant (O(n)) than usingfilterwithindexOf(O(n^2)).
