TypeScript MCQ Test: TypeScript MCQs - Practice Questions
1. What is the purpose of TypeScript's 'typeof' operator?
2. What TypeScript feature allows for specifying an exact set of string values for a type?
3. What does the 'keyof' keyword do in TypeScript?
4. What is the purpose of TypeScript's 'as' keyword?
5. What is the TypeScript feature used to combine multiple types into a single type?
6. What is TypeScript's 'namespace' used for?
7. What is TypeScript's 'export' keyword used for?
8. Which data type is used to represent a collection of values in TypeScript?
9. Which of the following is the correct way to define an interface for a function in TypeScript?
10. What is the TypeScript equivalent of JavaScript's 'constructor' function?
11. Which of the following is a valid way to define a string variable in TypeScript?
12. In TypeScript, how do you define a function?
13. In TypeScript, what is the 'this' keyword used for?
14. What is the purpose of namespaces in TypeScript?
15. Which TypeScript data type is used for variables that may have a 'null' or 'undefined' value?
16. What is the TypeScript equivalent of 'console.log()' in JavaScript?
17. In TypeScript, what is the difference between 'interface' and 'type' when defining a new type?
18. In TypeScript, what is the 'any' type used for?
19. What is the TypeScript equivalent of 'undefined' in JavaScript?
20. What is the purpose of TypeScript's 'enum'?
21. In TypeScript, what is the purpose of the 'import' statement?
22. Which TypeScript feature is used to apply metadata to classes, methods, or properties?
23. What is TypeScript's 'arrow function' syntax used for?
24. Which data type represents a collection of values in TypeScript?
25. Which TypeScript feature is used to make a property or method in a class inaccessible from outside the class?
26. What is the use of the 'this' parameter in TypeScript functions?
27. Which operator is used to specify a type guard in TypeScript?
28. How do you declare a readonly array in TypeScript?
29. What is the purpose of the 'interface' keyword in TypeScript?
30. Which utility type constructs a type by picking the set of properties 'K' from 'T'?