JavaScript Fundamentals Quiz Quiz

  1. Data Types

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

    1. String
    2. Number
    3. Boolean
    4. Object
    5. Undefined
  2. Variable Scope

    What is the scope of a variable declared with the keyword 'let' inside a block?

    1. Global
    2. Function
    3. Block
    4. Window
    5. Local
  3. Functions

    What is the purpose of a 'closure' in JavaScript?

    1. To close the browser window
    2. To bind two objects together
    3. To give access to an outer function’s scope from an inner function
    4. To prevent memory leaks
    5. To define the properties of an object
  4. Arrays

    Which method adds new elements to the end of an array and returns the new length?

    1. shift()
    2. unshift()
    3. pop()
    4. push()
    5. concat()
  5. Objects

    How do you access the value of a property named 'name' in an object called 'person'?

    1. person('name')
    2. person.Name
    3. person-u003Ename
    4. person[name]
    5. person.name
  6. Conditional Statements

    Which statement is used to execute a block of code only if a specified condition is true?

    1. for loop
    2. while loop
    3. if statement
    4. switch statement
    5. try...catch
  7. Loops

    Which type of loop iterates through the properties of an object?

    1. for loop
    2. while loop
    3. do...while loop
    4. for...in loop
    5. foreach loop
  8. Events

    Which event is triggered when an HTML element loses focus?

    1. onfocus
    2. onclick
    3. onblur
    4. onchange
    5. onselect
  9. String Methods

    Which string method is used to find the index of the first occurrence of a specified value in a string?

    1. search()
    2. indexAt()
    3. indexOf()
    4. findIndex()
    5. scan()
  10. Operators

    What does the '===' operator do in JavaScript?

    1. Assigns a value
    2. Checks for equality after type conversion
    3. Checks for equality without type conversion
    4. Declares a variable
    5. Adds two numbers