Which of the following is NOT a built-in function in JavaScript for interacting with the user through the browser?
confirm()
console.log()
alert()
prompt()
Which of the following is NOT a feature of JavaScript?
Object-oriented programming capabilities
Strongly typed language
Interpreted language
Client-side scripting language
What is the correct way to add an element 'apple' to the end of the array fruits = ['banana', 'orange']?
fruits = ['banana', 'orange']
fruits = ['apple']
fruits[2] = 'apple'
fruits.unshift('apple')
fruits.push('apple')
What is the purpose of the typeof operator in JavaScript?
typeof
Changes the data type of a variable
Determines the data type of a variable or expression
Checks if a variable is defined
Converts a variable to a string
Which operator is used to check for strict equality (value and type) in JavaScript?
===
=
==
!=
What is the result of the expression: 10 % 3?
10 % 3
10
0
1
3
Which statement can be used to exit a 'switch' statement?
return
break
continue
exit
Which method is used to select an HTML element with a specific ID?
getElementById()
getElementbyId()
querySelectorAll()
querySelector()
What is the correct syntax to change the text content of an element with the ID 'myElement' to 'Hello World!'?
document.querySelector('#myElement').innerHTML = 'Hello World!';
document.getElementById('myElement').innerText = 'Hello World!';
document.querySelector('#myElement').textContent = 'Hello World!';
document.getElementById('myElement').textContent = 'Hello World!';
What is the scope of a variable declared with 'var' inside a function?
Lexical scope
Block scope
Function scope
Global scope