JavaScript Essentials for QA: Cypress u0026 Playwright Quiz Quiz

Test your understanding of core JavaScript concepts relevant to QA roles in Cypress and Playwright. This easy quiz covers variables, asynchronous programming, promises, TypeScript basics, object and function syntax, array methods, and more.

  1. Variable Scope and Declaration

    Which keyword in JavaScript creates a block-scoped variable that can be reassigned, but not redeclared within the same scope?

    1. let
    2. const
    3. var
    4. vet
  2. Immutability of const

    If you declare an array using const in JavaScript, which statement is true?

    1. You can change the elements of the array, but not reassign the array variable.
    2. You cannot change the elements of the array at all.
    3. You can redeclare the variable in the same scope.
    4. You can reassign the array variable to a string.
  3. Synchronous vs Asynchronous

    In JavaScript, what is the main characteristic of asynchronous programming in relation to task execution?

    1. Tasks are always processed in the order they appear
    2. Tasks allow others to run while waiting for longer tasks to complete
    3. Tasks execute simultaneously with guaranteed timing
    4. Tasks block each other until each has finished
  4. Promise Handling

    Which of the following methods is used to handle errors from JavaScript Promises?

    1. .always()
    2. .fail()
    3. .catch()
    4. .then()
  5. Promise State

    A newly created JavaScript Promise is in which state before it is resolved or rejected?

    1. Pending
    2. Fulfilled
    3. Cancelled
    4. Resolved
  6. TypeScript Basics

    How is TypeScript different from JavaScript with regard to variable types?

    1. TypeScript does not allow any type checking.
    2. JavaScript is a superset of TypeScript.
    3. JavaScript supports types for variables at compile time.
    4. TypeScript requires types defined for variables, enabling compile-time checks.
  7. Objects vs Functions

    Which statement correctly distinguishes a JavaScript object from a function?

    1. Functions can be properties of objects, but objects primarily store key-value pairs.
    2. Objects must always have a name, functions do not.
    3. Functions store multiple key-value pairs; objects do not.
    4. Objects can only contain primitive values, functions cannot.
  8. Array Method Usage

    If you want to create a new array containing only even numbers from [1, 2, 3, 4, 5], which JavaScript array method should you use?

    1. filter()
    2. reduce()
    3. find()
    4. map()
  9. String Manipulation

    Given let str = 'Test'; which method returns the uppercase version of the string?

    1. str.toLower()
    2. str.isUpperCase()
    3. str.toUpperCase()
    4. str.uppercase()
  10. Class Syntax

    Which syntax correctly creates a JavaScript class named Animal with a constructor?

    1. new class Animal() { }
    2. let Animal = () =u003E { }
    3. Animal = function() { }
    4. class Animal { constructor() { } }