Data Types
Which of the following is not a primitive data type in JavaScript?
- String
- Number
- Boolean
- Object
- Undefined
Variable Scope
What is the scope of a variable declared with the keyword 'let' inside a block?
- Global
- Function
- Block
- Window
- Local
Functions
What is the purpose of a 'closure' in JavaScript?
- To close the browser window
- To bind two objects together
- To give access to an outer function’s scope from an inner function
- To prevent memory leaks
- To define the properties of an object
Arrays
Which method adds new elements to the end of an array and returns the new length?
- shift()
- unshift()
- pop()
- push()
- concat()
Objects
How do you access the value of a property named 'name' in an object called 'person'?
- person('name')
- person.Name
- person-u003Ename
- person[name]
- person.name
Conditional Statements
Which statement is used to execute a block of code only if a specified condition is true?
- for loop
- while loop
- if statement
- switch statement
- try...catch
Loops
Which type of loop iterates through the properties of an object?
- for loop
- while loop
- do...while loop
- for...in loop
- foreach loop
Events
Which event is triggered when an HTML element loses focus?
- onfocus
- onclick
- onblur
- onchange
- onselect
String Methods
Which string method is used to find the index of the first occurrence of a specified value in a string?
- search()
- indexAt()
- indexOf()
- findIndex()
- scan()
Operators
What does the '===' operator do in JavaScript?
- Assigns a value
- Checks for equality after type conversion
- Checks for equality without type conversion
- Declares a variable
- Adds two numbers