How do you access the value associated with the key 'name' in the object person = {name: 'John', age: 30}?
person = {name: 'John', age: 30}
person.name
person[0]
person['name']
person.get('name')
What is the purpose of the 'else if' statement in JavaScript?
To execute a block of code if the preceding 'if' condition is true.
To declare a variable.
To provide an alternative block of code to execute if the preceding 'if' or 'else if' conditions are false.
To define a loop that iterates a specific number of times.
Why is JavaScript considered a 'dynamic' language?
It enables changes to a webpage's content and behavior after it has loaded.
It enforces strict data types for variables.
It is a very old programming language.
It allows for the creation of visually appealing websites.
How do you access the value entered into a text input field in a form?
inputElement.value
inputElement.text
inputElement.getValue()
inputElement.data
What does the querySelector() method return when it finds multiple matching elements in the DOM?
querySelector()
null
An array of all matching elements
The first matching element
The last matching element
How can you change the text content of an HTML element using JavaScript?
All of the above
element.innerText = 'New text'
element.innerHTML = 'New text'
element.textContent = 'New text'
What is the difference between a function declaration and a function expression in JavaScript?
Function declarations can only be anonymous.
Function expressions are hoisted, while function declarations are not.
Function declarations are hoisted, while function expressions are not.
There is no difference; they are interchangeable.
Which event is commonly used for handling form submissions?
'click'
'submit'
'change'
'input'
Which property is used to set an attribute's value on an HTML element?
None of the above
element.setAttribute('attributeName', 'value')
Both of the above
element.attributeName = 'value'
Which method removes the first element from an array and returns it?
pop()
unshift()
slice()
shift()