JSE-40-01: JavaScript Certified Entry-Level Programmer — Questions and Answers
Question 1: In JavaScript certification, what is the purpose of automated testing?
- To replace manual code review entirely
- To catch regressions and verify functionality continuously (Correct answer)
- To increase server costs
- To slow down development
Correct answer: To catch regressions and verify functionality continuously
Automated testing catches regressions early and verifies that functionality works as expected, providing confidence in code changes.
Question 2: What role does collaboration play in error handling for JavaScript professionals?
- It is only needed in emergencies
- It reduces individual accountability
- It slows down work unnecessarily
- It enhances outcomes through diverse perspectives and shared expertise (Correct answer)
Correct answer: It enhances outcomes through diverse perspectives and shared expertise
Collaboration leverages diverse perspectives and combined expertise to achieve better outcomes than any individual could alone.
Question 3: What is the most important professional competency for JavaScript certification in dom manipulation?
- Ability to work alone exclusively
- Speed of task completion
- Memorization of all reference materials
- Deep knowledge combined with practical application skills (Correct answer)
Correct answer: Deep knowledge combined with practical application skills
Professional competency requires both deep knowledge of the subject matter and the ability to apply that knowledge in practical situations.
Question 4: What is a RangeError in JavaScript?
- An error from network request failures
- An error when a value is not within the allowed range (Correct answer)
- An error when a variable is out of scope
- An error when accessing an array out of bounds
Correct answer: An error when a value is not within the allowed range
A `RangeError` is thrown when a value is not within the allowed range. Examples: passing an invalid length to `new Array(-1)`, calling `toFixed()` with a number out of range, or infinite recursion causing a stack overflow.
Question 5: How do you add a CSS class to a DOM element?
- element.className = 'myClass'
- element.classList.add('myClass') (Correct answer)
- element.style.class = 'myClass'
- element.addStyle('myClass')
Correct answer: element.classList.add('myClass')
`element.classList.add('myClass')` is the modern and recommended way to add a CSS class. It preserves existing classes, unlike `element.className = 'myClass'` which replaces all classes.
Question 6: Which professional attribute is most valued in error handling within the JavaScript field?
- Accountability and commitment to standards (Correct answer)
- Prioritizing personal convenience
- Avoiding challenging situations
- Working in isolation
Correct answer: Accountability and commitment to standards
Accountability and commitment to professional standards build trust and ensure consistent, high-quality practice.
Question 7: Which of the following correctly overrides a parent method in a subclass?
- Call `super.remove(methodName)`
- Define a method with the same name in the subclass (Correct answer)
- Use `override` keyword before the method
- Reassign `Parent.prototype.method`
Correct answer: Define a method with the same name in the subclass
Defining a method with the same name in the subclass shadows the parent's version due to prototype chain lookup order.
Question 8: What does the `*` quantifier mean in a regular expression?
- Exactly one occurrence of the preceding token
- One or more occurrences of the preceding token
- Zero or one occurrence of the preceding token
- Zero or more occurrences of the preceding token (Correct answer)
Correct answer: Zero or more occurrences of the preceding token
`*` is a greedy quantifier that matches zero or more consecutive occurrences of the preceding element, making it optional.
Question 9: Which standard construct for data validation is available in the development environment?
- Super controlled loop constructs
- Validation constructs
- All of the above (Correct answer)
- case sensitivity check
Correct answer: All of the above
Data validation in a development environment involves various techniques. This can include using specific validation constructs (like HTML5 input types and attributes, or JavaScript validation libraries), super controlled loop constructs for iterating and checking data, and ensuring case sensitivity checks where appropriate for data integrity. All these methods contribute to robust data validation.
Question 10: Which of the following is NOT a valid way to declare a variable in modern JavaScript?
- var x = 1
- def x = 1 (Correct answer)
- const x = 1
- let x = 1
Correct answer: def x = 1
`def` is not a JavaScript keyword; variables are declared with `var`, `let`, or `const`.
Question 11: What is event delegation?
- Assigning multiple handlers to one event
- Attaching an event listener to a parent element to handle events from its children (Correct answer)
- Delegating event handling to Web Workers
- Passing event objects between components
Correct answer: Attaching an event listener to a parent element to handle events from its children
Event delegation is a technique where a single event listener is added to a parent element to handle events from multiple child elements, using event bubbling. The `event.target` property identifies which child triggered the event.
Question 12: What does `Array.prototype.some()` return?
- The number of elements that pass the test
- The first element that passes the test
- true if at least one element passes the test, otherwise false (Correct answer)
- An array of elements that pass the test
Correct answer: true if at least one element passes the test, otherwise false
`some()` tests whether at least one element in the array passes the test implemented by the provided function. It returns `true` immediately when a matching element is found, `false` if none match.
Question 13: What is the output of `console.log([] instanceof Array)` in JavaScript?
- undefined
- true (Correct answer)
- false
- TypeError
Correct answer: true
`Array.prototype` is in the prototype chain of any array literal, so `instanceof Array` returns `true`.
Question 14: What is the purpose of the `modulepreload` link relation?
- Preloads CSS modules before rendering
- Registers a service worker module
- Instructs the browser to fetch and parse an ES module early to improve performance (Correct answer)
- Defers module loading until user interaction
Correct answer: Instructs the browser to fetch and parse an ES module early to improve performance
`<link rel="modulepreload">` tells the browser to fetch, parse, and compile an ES module in advance, reducing latency.
Question 15: Which Jest matcher should you use to test that an async function rejects with a specific error?
- expect(fn).toReject()
- await expect(fn).throwsAsync()
- await expect(promise).rejects.toThrow() (Correct answer)
- expect(fn()).toThrow()
Correct answer: await expect(promise).rejects.toThrow()
await expect(promise).rejects.toThrow() correctly handles the async rejection and asserts the thrown error type or message.
Question 16: In JavaScript certification, what is the purpose of automated testing?
- To increase server costs
- To replace manual code review entirely
- To slow down development
- To catch regressions and verify functionality continuously (Correct answer)
Correct answer: To catch regressions and verify functionality continuously
Automated testing catches regressions early and verifies that functionality works as expected, providing confidence in code changes.
Question 17: What happens if you call a class constructor without the `new` keyword?
- It returns undefined
- It throws a TypeError (Correct answer)
- It works just like a regular function
- It returns the global object
Correct answer: It throws a TypeError
Classes enforce being called with `new`; calling them without it throws a `TypeError: Class constructor cannot be invoked without 'new'`.
Question 18: We state that a class B can extend another class A when it can.
- B is the superclass and A is the subclass
- Both A and B are the superclass
- Both A and B are the subclass
- A is the superclass and B is the subclass (Correct answer)
Correct answer: A is the superclass and B is the subclass
In object-oriented programming, when class B `extends` class A, it means that class B inherits properties and methods from class A. In this relationship, class A is referred to as the superclass (or parent class), and class B is the subclass (or child class). The subclass B can then add its own unique properties and methods or override those inherited from the superclass A.
Question 19: What types of errors can be thrown in JavaScript?
- Only errors defined by the browser
- Only subclasses of Error
- Only Error objects
- Any value including strings, numbers, and objects (Correct answer)
Correct answer: Any value including strings, numbers, and objects
JavaScript's `throw` statement can throw any value — strings, numbers, objects, or Error instances. However, best practice is to throw Error objects or subclasses to preserve stack traces.
Question 20: What does `event.preventDefault()` do?
- Prevents the browser's default action for the event (Correct answer)
- Removes all event listeners from the element
- Cancels the event object
- Stops the event from bubbling up the DOM
Correct answer: Prevents the browser's default action for the event
`event.preventDefault()` tells the browser not to execute its default behavior for the event. For example, preventing a form from submitting, stopping a link from navigating, or blocking a checkbox from toggling.
Question 21: What does `document.querySelector()` return?
- An array of all matching elements
- A NodeList of all matching elements
- The first element matching the CSS selector (Correct answer)
- A boolean indicating whether the element exists
Correct answer: The first element matching the CSS selector
`document.querySelector()` returns the first Element within the document that matches the provided CSS selector string, or `null` if no match is found.
Question 22: What is property shorthand in ES6 object literals?
- Using getters and setters
- Defining methods without the function keyword
- Using computed property names in brackets
- Omitting the value when variable name matches the property name (Correct answer)
Correct answer: Omitting the value when variable name matches the property name
Property shorthand allows you to omit the value when the property name matches a variable in scope: instead of `{ name: name, age: age }`, you can write `{ name, age }`.
Question 23: What does `Array.prototype.reduce()` do?
- Splits an array into chunks
- Removes duplicate values from an array
- Applies a function against an accumulator and each element to reduce the array to a single value (Correct answer)
- Converts an array to an object
Correct answer: Applies a function against an accumulator and each element to reduce the array to a single value
`reduce()` executes a reducer function on each element of the array, accumulating the result into a single output value. It takes a callback and an optional initial value.
Question 24: What value does `require()` return when you require a JSON file in Node.js?
- A ReadStream for the file
- A raw string of the file contents
- A Buffer containing the file bytes
- A parsed JavaScript object (Correct answer)
Correct answer: A parsed JavaScript object
Node.js automatically parses JSON files when they are `require()`d, returning a ready-to-use JavaScript object.
Question 25: What does `Object.getPrototypeOf(obj)` return?
- The keys of obj
- The prototype of obj (Correct answer)
- The constructor of obj
- A copy of obj
Correct answer: The prototype of obj
`Object.getPrototypeOf(obj)` returns the prototype (i.e., the value of the internal `[[Prototype]]`) of the specified object.
Question 26: What is the Temporal Dead Zone (TDZ)?
- A period when setTimeout callbacks are delayed
- The time between entering a block scope and a `let`/`const` declaration being initialized (Correct answer)
- A deprecated JavaScript feature
- A zone where global variables are undefined
Correct answer: The time between entering a block scope and a `let`/`const` declaration being initialized
The Temporal Dead Zone is the region in a block scope where `let` or `const` variables are hoisted but not yet initialized. Accessing them in this zone throws a `ReferenceError`.
Question 27: In Mocha, which hook runs once before all tests in a describe block?
- afterAll
- beforeEach
- setup
- before (Correct answer)
Correct answer: before
The `before` hook in Mocha runs once before all tests within its enclosing describe block.
Question 28: Which syntax correctly re-exports a named export `helper` from `./utils.js`?
- re-export { helper } from './utils.js';
- export { helper } from './utils.js'; (Correct answer)
- export default helper from './utils.js';
- import { helper } from './utils.js'; export helper;
Correct answer: export { helper } from './utils.js';
The `export { name } from 'module'` syntax re-exports without importing into the current scope.
Question 29: What does `String.prototype.replace()` do?
- Replaces characters by position
- Replaces the first occurrence of a pattern (string or regex without `g` flag) with a replacement (Correct answer)
- Replaces ALL occurrences of a string or regex pattern
- Removes a substring from the string
Correct answer: Replaces the first occurrence of a pattern (string or regex without `g` flag) with a replacement
`replace(pattern, replacement)` returns a new string with the first match replaced. To replace all occurrences with a string pattern, use `replaceAll()` or a regex with the `g` flag.
JSE-40-01: JavaScript Certified Entry-Level Programmer
The JSE-40-01 certification validates foundational JavaScript programming skills including core syntax, variables and data types, operators, control flow, functions, and error handling. It is issued by the JavaScript Institute (OpenEDG) for entry-level developers.
Exam Rules
- You can skip questions and return to them later
- Flag questions for review before submitting
- No feedback shown until you submit the entire exam
- Unanswered questions count as wrong — answer everything
- 10 pretest questions are mixed in and don't affect your score
- Timer auto-submits when time runs out
- Your progress is auto-saved every 30 seconds