Which property is used to set an attribute's value on an HTML element?
Both of the above
None of the above
element.attributeName = 'value'
element.setAttribute('attributeName', 'value')
What will the following code snippet log to the console?
console.log(5 + '5');
10
Error
55
NaN
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.name
person[0]
person.get('name')
In JavaScript, what does it mean for a function to have a closure?
It can modify global variables.
It can be passed as an argument to other functions.
It can access variables from its surrounding scope, even after the outer function has finished executing.
It can access its own parameters.
Why is JavaScript considered a 'dynamic' language?
It enforces strict data types for variables.
It enables changes to a webpage's content and behavior after it has loaded.
It is a very old programming language.
It allows for the creation of visually appealing websites.
How do you define default parameter values in a JavaScript function?
By using the 'defaults' keyword.
Default parameters are not supported in JavaScript.
By assigning values to parameters directly within the function definition.
Using an if statement inside the function body.
What is the scope of a variable declared inside a function in JavaScript?
Function scope
Block scope
Local scope
Global scope
What is the difference between the 'break' and 'continue' statements in a loop?
'break' exits the loop entirely, while 'continue' skips the current iteration and continues with the next.
'break' and 'continue' both skip the current iteration.
'break' skips the current iteration, while 'continue' exits the loop entirely.
'break' and 'continue' both exit the loop entirely.
What is the purpose of the return keyword in a function?
return
It sends a value back from the function to the caller.
It assigns a value to a variable.
It prints a value to the console.
It specifies the data type of the function.
What is the purpose of event.preventDefault() in form handling?
event.preventDefault()
Validates the form data
Stops the form from submitting
Clears the form fields
Submits the form data asynchronously