CIW JavaScript Specialist Free Sample Questions

Description

Covers JavaScript variables, functions, methods and events, debugging and program flow control, the Document Object Model, interactive forms, and JavaScript libraries, frameworks and AJAX.

12 free sample questions150 in the full practice test

Try simulator

1D0-735 Sample Questions

  1. Question 1

    Beginner

    Essential JavaScript Principles and Practices · Variables, Data Types, and Operators

    A developer is refactoring a legacy JavaScript application to use modern ES6 syntax. The original code uses var for variable declaration inside a for loop, causing scope leakage. Which variable declaration keyword should be used to ensure the loop counter is block-scoped and not accessible outside the loop?

    Answer and explanation

    Correct answer: D

    The let keyword declares a block-scoped local variable. Using let in a for loop ensures that the variable is only available within the loop block. var is function-scoped, and const cannot be used for a loop counter that needs to be incremented.

  2. Question 2

    Intermediate

    Essential JavaScript Principles and Practices · Variables, Data Types, and Operators

    You are writing a function that processes user input. The input is received as a string '42', but you need to perform strict mathematical addition with another number, not concatenation. Which operator or function is best suited to convert this string to a number while preserving decimal precision if present?

    Answer and explanation

    Correct answer: D

    parseFloat() parses a string argument and returns a floating-point number. Unlike parseInt(), which truncates decimals, parseFloat() preserves them, making it the best choice for general numeric conversion where precision matters.

  3. Question 3

    Intermediate

    Essential JavaScript Principles and Practices · Variables, Data Types, and Operators

    Analyze the following code snippet. What will be the value of result after execution?

    var x = 10;
    var y = '5';
    var result = (x > 5) && (y === 5) ? 'Pass' : 'Fail';
    
    Answer and explanation

    Correct answer: B

    The expression evaluates as follows: (x > 5) is true. (y === 5) uses strict equality. Since y is a string '5' and 5 is a number, this is false. true && false results in false. The ternary operator returns the second value, 'Fail'.

  4. Question 4

    Intermediate

    Essential JavaScript Principles and Practices · Functions, Methods, and Events

    A developer needs to define a function that will be passed as a callback to an event listener. It is crucial that the this keyword inside the callback refers to the lexical scope where the function was defined, rather than the element that triggered the event. Which type of function syntax handles this automatically?

    Answer and explanation

    Correct answer: D

    Arrow functions do not have their own this context; they inherit this from the enclosing lexical context. This makes them ideal for callbacks where you want to preserve the context of the surrounding code.

  5. Question 5

    Beginner

    Essential JavaScript Principles and Practices · JavaScript Characteristics and Programming Practices

    Which of the following statements accurately describes the behavior of JavaScript when running in a browser environment compared to a server-side environment like Node.js?

    Answer and explanation

    Correct answer: D

    The Document Object Model (DOM) is a browser-specific API that allows JavaScript to interact with HTML and CSS. Server-side environments like Node.js do not have a DOM by default.

  6. Question 6

    Beginner

    Essential JavaScript Principles and Practices · Variables, Data Types, and Operators

    You need to create a variable that cannot be reassigned after its initial declaration. Attempting to reassign it should throw an error. Which keyword must be used?

    Answer and explanation

    Correct answer: B

    The const keyword creates a read-only reference to a value. It does not mean the value itself is immutable (if it's an object), but the variable identifier cannot be reassigned.

Register free for 6 more questions

Or unlock all 150 1D0-735 questions with explanations, timed mode and flashcards.