JavaScript Basics: 10 Essential Interview Questions Quiz

  1. Primitive Data Types

    Which of the following is NOT a primitive data type in JavaScript?

    1. A. string
    2. B. object
    3. C. boolean
    4. D. number
    5. E. symbol
  2. Undefined vs Null

    If a variable is declared but not assigned a value in JavaScript, what is its value?

    1. A. null
    2. B. zero
    3. C. undefined
    4. D. false
    5. E. empty
  3. Undeclared Variables

    In JavaScript, what does 'undeclared' mean in the context of variables?

    1. A. Using a variable declared with var/let/const but unassigned
    2. B. Using a variable that was never declared with var/let/const
    3. C. A variable set to undefined
    4. D. A variable set to null
    5. E. A variable declared with double equals
  4. Variable Declaration

    Which of the following are correct ways to declare a variable in JavaScript?

    1. A. declare x = 5;
    2. B. let x = 5;
    3. C. assign x = 5;
    4. D. varLet x = 5;
    5. E. variable x = 5;
  5. Var, Let, and Const Differences

    Which statement correctly describes the variable declared with const?

    1. A. Can be redeclared and updated
    2. B. Is globally scoped and can be reassigned
    3. C. Cannot be reassigned or updated once set
    4. D. Automatically gets undefined value
    5. E. Can only be used in loops
  6. Hoisting Definition

    What does 'hoisting' mean in JavaScript?

    1. A. Running all code twice automatically
    2. B. Moving all statements to the bottom of the file
    3. C. Moving variable and function declarations to the top of their scope
    4. D. A process where variables are deleted after use
    5. E. Sorting array elements to the top
  7. Callback Functions

    Which best describes a callback function in JavaScript?

    1. A. A function that runs only when an error occurs
    2. B. A function that is never called
    3. C. A function passed as an argument to another function and invoked inside
    4. D. A function that returns another function
    5. E. A function called twice in a row
  8. Asynchronous Handling

    Which is NOT a valid way to handle asynchronous operations in JavaScript?

    1. A. Callback functions
    2. B. Promises
    3. C. async/await
    4. D. Synchronous loops
    5. E. setTimeout
  9. Equality Operators

    What is the main difference between '==' and '===' in JavaScript?

    1. A. '==' compares only types, '===' compares only values
    2. B. '==' does type coercion, '===' checks both type and value without coercion
    3. C. '==' is for numbers, '===' is for strings
    4. D. '==' is slower than '==='
    5. E. They are always interchangeable
  10. The DOM

    What does the Document Object Model (DOM) represent in JavaScript?

    1. A. A list of all functions in a script
    2. B. A database of user data
    3. C. A programming interface for HTML and XML documents
    4. D. The output of the console.log function
    5. E. A mathematical model for algorithms