# TypeScript ขั้นสูง (Angular) > Generics, conditional types, mapped types, utility types, decorators, namespaces, modules - 20 คำถามสัมภาษณ์ - Junior - [คำถามสัมภาษณ์: Angular](https://sharpskill.dev/th/technologies/angular/interview-questions.md) ## 1. Generic ใน TypeScript คืออะไร? **คำตอบ** Generic ช่วยให้สร้างคอมโพเนนต์ที่นำกลับมาใช้ใหม่ได้ซึ่งทำงานกับหลายประเภทแทนที่จะเป็นเพียงประเภทเดียว Generics ใช้พารามิเตอร์ประเภท (เช่น T) เพื่อแสดงประเภทใดๆ ก็ตาม สิ่งนี้ทำให้สามารถเขียนโค้ดที่ type-safe โดยไม่ต้องเสียสละความยืดหยุ่น เช่น ฟังก์ชันที่จัดการอาร์เรย์ของประเภทใดๆ ในขณะที่ยังคงรักษาข้อมูลประเภทไว้ ## 2. บทบาทของ utility type Partial คืออะไร? **คำตอบ** Partial แปลงคุณสมบัติทั้งหมดของประเภท T ให้เป็นคุณสมบัติแบบเลือกได้ สิ่งนี้มีประโยชน์อย่างยิ่งสำหรับฟังก์ชันการอัปเดตที่ต้องแก้ไขเฉพาะบางฟิลด์เท่านั้น ตัวอย่างเช่น ในการอัปเดตผู้ใช้ สามารถระบุเพียงชื่อโดยไม่ต้องระบุฟิลด์อื่นๆ ทั้งหมด TypeScript รับประกันว่าจะส่งผ่านได้เฉพาะคุณสมบัติที่มีอยู่เท่านั้น ## 3. ความแตกต่างระหว่าง Pick และ Omit คืออะไร? **คำตอบ** Pick เลือกเฉพาะคุณสมบัติ K จากประเภท T โดยสร้างประเภทใหม่ที่มีเฉพาะคุณสมบัติเหล่านั้น ในทางกลับกัน Omit ไม่รวมคุณสมบัติ K จากประเภท T โดยสร้างประเภทใหม่ที่มีคุณสมบัติทั้งหมดยกเว้นคุณสมบัติที่ระบุ Pick มีประโยชน์สำหรับการสร้างมุมมองบางส่วนที่มีฟิลด์ที่จำเป็น ในขณะที่ Omit เหมาะสำหรับการสร้างประเภทโดยไม่มีฟิลด์ที่ละเอียดอ่อนบางอย่าง เช่น รหัสผ่าน ## มีอีก 17 คำถาม - จะจำกัด generic ให้อยู่ในประเภทบางอย่างได้อย่างไร? - Utility type ใดที่ทำให้คุณสมบัติทั้งหมดเป็นแบบบังคับ? สมัครฟรี: https://sharpskill.dev/th/login ## หัวข้อสัมภาษณ์ Angular อื่นๆ - [พื้นฐาน TypeScript](https://sharpskill.dev/th/technologies/angular/interview-questions/typescript-basics.md): 25 คำถาม, Junior - [พื้นฐาน Angular](https://sharpskill.dev/th/technologies/angular/interview-questions/angular-fundamentals.md): 20 คำถาม, Junior - [คอมโพเนนต์และวงจรชีวิต](https://sharpskill.dev/th/technologies/angular/interview-questions/components-lifecycle.md): 20 คำถาม, Junior - [Services & Dependency Injection](https://sharpskill.dev/th/technologies/angular/interview-questions/services-dependency-injection.md): 20 คำถาม, Junior - [การจัดระเบียบโมดูล Angular](https://sharpskill.dev/th/technologies/angular/interview-questions/modules-organization.md): 22 คำถาม, Mid-Level - [Angular CLI](https://sharpskill.dev/th/technologies/angular/interview-questions/angular-cli.md): 18 คำถาม, Junior - [Directives และ Pipes](https://sharpskill.dev/th/technologies/angular/interview-questions/directives-pipes.md): 22 คำถาม, Mid-Level - [Routing และการนำทาง](https://sharpskill.dev/th/technologies/angular/interview-questions/routing-navigation.md): 24 คำถาม, Mid-Level - [Reactive Forms](https://sharpskill.dev/th/technologies/angular/interview-questions/forms-reactive.md): 26 คำถาม, Mid-Level - [Template-driven Forms](https://sharpskill.dev/th/technologies/angular/interview-questions/forms-template-driven.md): 16 คำถาม, Mid-Level - [พื้นฐาน RxJS](https://sharpskill.dev/th/technologies/angular/interview-questions/rxjs-fundamentals.md): 22 คำถาม, Mid-Level - [Operator ของ RxJS](https://sharpskill.dev/th/technologies/angular/interview-questions/rxjs-operators.md): 24 คำถาม, Mid-Level - [HttpClient และการเรียก API](https://sharpskill.dev/th/technologies/angular/interview-questions/http-client.md): 22 คำถาม, Mid-Level - [การจัดการ state พื้นฐาน](https://sharpskill.dev/th/technologies/angular/interview-questions/state-management-basics.md): 20 คำถาม, Mid-Level - [Change Detection](https://sharpskill.dev/th/technologies/angular/interview-questions/change-detection.md): 20 คำถาม, Mid-Level - [Angular Signals](https://sharpskill.dev/th/technologies/angular/interview-questions/angular-signals.md): 20 คำถาม, Mid-Level - [Standalone Components](https://sharpskill.dev/th/technologies/angular/interview-questions/standalone-components.md): 18 คำถาม, Mid-Level - [การทำ Unit Testing ใน Angular](https://sharpskill.dev/th/technologies/angular/interview-questions/testing-unit.md): 22 คำถาม, Mid-Level - [การทดสอบ End-to-End](https://sharpskill.dev/th/technologies/angular/interview-questions/testing-e2e.md): 18 คำถาม, Mid-Level - [Build และการเพิ่มประสิทธิภาพ](https://sharpskill.dev/th/technologies/angular/interview-questions/build-optimization.md): 20 คำถาม, Mid-Level - [พื้นฐาน NgRx](https://sharpskill.dev/th/technologies/angular/interview-questions/ngrx-fundamentals.md): 24 คำถาม, Senior - [NgRx ขั้นสูง](https://sharpskill.dev/th/technologies/angular/interview-questions/ngrx-advanced.md): 24 คำถาม, Senior - [สถาปัตยกรรม Angular](https://sharpskill.dev/th/technologies/angular/interview-questions/angular-architecture.md): 22 คำถาม, Senior - [การปรับแต่งประสิทธิภาพ](https://sharpskill.dev/th/technologies/angular/interview-questions/performance-optimization.md): 22 คำถาม, Senior - [ความปลอดภัยและแนวทางปฏิบัติที่ดี](https://sharpskill.dev/th/technologies/angular/interview-questions/security-best-practices.md): 20 คำถาม, Senior - [รูปแบบ RxJS ขั้นสูง](https://sharpskill.dev/th/technologies/angular/interview-questions/advanced-rxjs-patterns.md): 22 คำถาม, Senior - [Angular Universal และ SSR](https://sharpskill.dev/th/technologies/angular/interview-questions/angular-universal-ssr.md): 20 คำถาม, Senior - [Angular Micro-frontends](https://sharpskill.dev/th/technologies/angular/interview-questions/micro-frontends-angular.md): 20 คำถาม, Senior --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/th/technologies/angular/interview-questions/typescript-advanced