Posts

Object-Oriented Programming in JavaScript MCQs

Key ES6+ JavaScript Features Template Literals and Modern Syntax

1. What is the purpose of a constructor in a JavaScript class?

2. How do you access properties of an object using the `this` keyword?

3. What does the `super` keyword do in a derived class?

4. Which of the following is a correct way to create a regular expression in JavaScript?

5. What method would you use to test if a string contains a specific pattern using regex?

6. How do you replace a substring in a string using a regular expression?

7. What does the regex pattern `/\d+/` match?

8. Which method returns an array of matches when using a regular expression?

9. What does the `g` flag in a regex pattern do?

10. Which character is used to denote the start of a line in a regex pattern?

11. What will `instanceof` return if an object is an instance of a class?

12. Which keyword is used to create a new class in JavaScript?

13. What is a method in a JavaScript class?

14. What does the regex pattern `/^a/` match?

15. Which regex pattern would match any character except a newline?

16. What does the `i` flag do in a regex pattern?

17. How do you match one or more whitespace characters in a regex pattern?

18. Which method can be used to check if a string matches a regex pattern?

19. What does the regex pattern `/[a-z]/` match?

20. How do you escape a special character in a regex pattern?

Post a Comment

Your comment will be visible after approval.
© TechTestLog. All rights reserved. Premium By Raushan Design
//My script