TypeScript Basics
Primitive types, interfaces, union types, literal types, type assertions, type guards, narrowing
1Which TypeScript primitive type represents a textual value?
Which TypeScript primitive type represents a textual value?
Answer
The string type represents all textual values in TypeScript, whether delimited by single quotes, double quotes, or backticks for template literals. It is the appropriate type for storing text, names, messages, URLs, or any textual content in applications.
2Which type to use for a variable that can contain any value without type checking?
Which type to use for a variable that can contain any value without type checking?
Answer
The any type completely disables TypeScript type checking for a variable. It allows assigning any value and performing all operations without compilation errors. However, its use is discouraged as it eliminates the benefits of type safety.
3Which type represents the absence of a return value in a function?
Which type represents the absence of a return value in a function?
Answer
The void type indicates that a function does not return any meaningful value. It is used for functions that perform actions without producing a result, such as display or state modification functions. A void function can return undefined implicitly.
What is the main difference between null and undefined in TypeScript?
Which type to use for a value whose type is unknown and requires verification before use?
+22 interview questions
Other Angular interview topics
TypeScript Advanced
Angular Fundamentals
Components & Lifecycle
Services & Dependency Injection
Angular Modules Organization
Angular CLI
Directives & Pipes
Routing & Navigation
Reactive Forms
Template-driven Forms
RxJS Fundamentals
RxJS Operators
HttpClient & API Calls
Basic State Management
Change Detection
Angular Signals
Standalone Components
Angular Unit Testing
End-to-End Testing
Build & Optimization
NgRx Fundamentals
NgRx Advanced
Angular Architecture
Performance Optimization
Security & Best Practices
Advanced RxJS Patterns
Angular Universal & SSR
Angular Micro-frontends
Master Angular for your next interview
Access all questions, flashcards, technical tests, code review exercises and interview simulators.
Start for free