1. What does JavaScript do?
Answer: It is used for creating web pages.
2. How do you display a message in the browser's console?
Answer: console.log("Hello World");
3. What is a JavaScript statement?
Answer: A statement performs an action.
4. What is the correct syntax to create a function in JavaScript?
Answer: function myFunction() { }
5. How do you write a single-line comment in JavaScript?
Answer: // This is a comment
6. How do you declare a variable in JavaScript?
Answer: var x;
7. What does the '==' operator do in JavaScript?
Answer: Compares two values for equality.
8. What will the expression 5 + 10 + "10" evaluate to in JavaScript?
Answer: 1510
9. What is the data type of the following value: 42?
Answer: Number
10. How do you call a function named "myFunction" in JavaScript?
Answer: myFunction();
11. How do you access the value of the "name" property of an object in JavaScript?
Answer: object.name
12. Which event is triggered when the user clicks on an HTML element?
Answer: onclick
13. How do you get the length of a string in JavaScript?
Answer: string.length
14. How do you generate a random number between 0 and 1 in JavaScript?
Answer: Math.random()
15. How do you round a number to the nearest integer in JavaScript?
Answer: Math.round()
16. What happens to variables declared using var before they are initialized in JavaScript?
var
Answer: They are hoisted to the top.
17. What is the correct syntax for an arrow function in JavaScript?
Answer: const myFunction = () => { }
18. How do you access an element with the ID "myElement" in JavaScript?
Answer: document.getElementById("myElement")
19. How do you define a class in JavaScript?
Answer: class MyClass { }
20. How do you import a module in JavaScript?
Answer: import myModule from './myModule.js';