You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// 8. **How do TypeScript and JavaScript handle null and undefined?**
240
+
// - In JavaScript, `null` is an object and `undefined` is a primitive value.
241
+
// - In TypeScript, `null` and `undefined` are types, and strict null checks can be enforced.
242
+
243
+
244
+
245
+
// ==============================
246
+
// 🎯 3. Interview Placement Questions
247
+
// ==============================
248
+
249
+
250
+
// 📝 TypeScript Interview Questions:
251
+
// 1. **Differences between JavaScript and TypeScript?**
252
+
// - **JavaScript**: Dynamic typing, no type annotations.
253
+
// - **TypeScript**: Statically typed with support for interfaces, types, and other features.
254
+
255
+
// 2. **What is type inference?**
256
+
// Type inference is when TypeScript automatically deduces the type of a variable based on its value or context, reducing the need for explicit type annotations.
257
+
258
+
// 3. **Difference between interface and type?**
259
+
// - **Interface**: Defines the shape of an object, can be merged using declaration merging.
260
+
// - **Type**: Defines the shape and can also be used to create unions or intersections.
261
+
262
+
// 4. **What are generics?**
263
+
// Generics allow functions or classes to work with any type while preserving the type of the input and output values, making code reusable and type-safe.
264
+
265
+
// 5. **Explain optional properties.**
266
+
// Optional properties in interfaces are defined using a `?`, meaning that they may or may not be present in an object.
267
+
268
+
// 6. **Difference between any and unknown?**
269
+
// - **any**: Can hold any type and can be assigned to any type, bypassing type safety.
270
+
// - **unknown**: Safer than **any**, requires type checking before performing operations.
271
+
272
+
// 7. What are mapped types?
273
+
// Mapped types allow you to create new types by transforming properties of an existing type.
// - **private**: Accessible only within the class.
278
+
// - **protected**: Accessible within the class and subclasses.
279
+
280
+
// 9. **Explain enums.**
281
+
// Enums allow defining a set of named constants, often used for values that have a limited set of options.
16
282
283
+
// 10. **How does TypeScript handle null and undefined?**
284
+
// TypeScript provides stricter handling of **null** and **undefined**. You can enable strict null checks to ensure that **null** and **undefined** are handled explicitly.
0 commit comments