# Core API ของ Node.js (Node.js / NestJS) > fs, path, events, process, os, streams, buffers, child_process, worker threads - 25 คำถามสัมภาษณ์ - Junior - [คำถามสัมภาษณ์: Node.js / NestJS](https://sharpskill.dev/th/technologies/node-nestjs/interview-questions.md) ## 1. เมธอดใดของโมดูล fs ที่ใช้อ่านไฟล์แบบอะซิงโครนัส? **คำตอบ** fs.readFile() อ่านไฟล์ทั้งหมดแบบอะซิงโครนัสและส่งคืนเนื้อหาผ่าน callback เมธอด fs.read() มีอยู่แต่ทำงานกับ file descriptor สำหรับการอ่านบางส่วน fs.readFileSync() เป็นเวอร์ชันซิงโครนัส API อะซิงโครนัสนี้ช่วยหลีกเลี่ยงการบล็อก event loop ระหว่างการดำเนินการ I/O ที่มีต้นทุนสูง ## 2. ความแตกต่างหลักระหว่าง path.join() และ path.resolve() คืออะไร? **คำตอบ** path.join() เพียงต่อส่วนของพาธเข้าด้วยกัน ในขณะที่ path.resolve() จะแปลงพาธให้เป็นพาธสัมบูรณ์โดยอ้างอิงจากไดเรกทอรีปัจจุบัน ตัวอย่างเช่น path.join('a', 'b') คืนค่า 'a/b' ส่วน path.resolve('a', 'b') คืนค่าพาธสัมบูรณ์เต็มรูปแบบเช่น /current/dir/a/b ใช้ path.resolve() เพื่อให้ได้พาธสัมบูรณ์ที่รับประกันได้ ## 3. ควรใช้ flag ใดกับ fs.writeFile() เพื่อต่อท้ายเนื้อหาโดยไม่เขียนทับไฟล์? **คำตอบ** flag 'a' (append) เปิดไฟล์ในโหมดต่อท้าย โดยรักษาเนื้อหาเดิมไว้และเพิ่มต่อท้าย flag เริ่มต้น 'w' (write) จะเขียนทับไฟล์ ยังมี flag อื่นๆ เช่น 'r' (read), 'wx' (write exclusive) เป็นต้น flag สืบทอดมาจากระบบ POSIX และควบคุมพฤติกรรมการเปิดไฟล์อย่างละเอียด ## มีอีก 22 คำถาม - เมธอดใดของโมดูล path ที่ทำให้พาธเป็นมาตรฐานโดยแปลงส่วน . และ ..? - จะสร้างไดเรกทอรีและไดเรกทอรีแม่ที่ขาดหายไปทั้งหมดด้วย fs ได้อย่างไร? สมัครฟรี: https://sharpskill.dev/th/login ## หัวข้อสัมภาษณ์ Node.js / NestJS อื่นๆ - [พื้นฐาน Node.js](https://sharpskill.dev/th/technologies/node-nestjs/interview-questions/nodejs-fundamentals.md): 20 คำถาม, Junior - [การเขียนโปรแกรมแบบอะซิงโครนัส](https://sharpskill.dev/th/technologies/node-nestjs/interview-questions/asynchronous-programming.md): 25 คำถาม, Junior - [พื้นฐาน Express.js](https://sharpskill.dev/th/technologies/node-nestjs/interview-questions/express-basics.md): 20 คำถาม, Junior - [พื้นฐาน NestJS](https://sharpskill.dev/th/technologies/node-nestjs/interview-questions/nestjs-fundamentals.md): 23 คำถาม, Junior - [การออกแบบ REST API](https://sharpskill.dev/th/technologies/node-nestjs/interview-questions/rest-api-design.md): 20 คำถาม, Junior - [การตรวจสอบความถูกต้องและ DTO](https://sharpskill.dev/th/technologies/node-nestjs/interview-questions/validation-dto.md): 20 คำถาม, Junior - [เอกสาร API และ Contract](https://sharpskill.dev/th/technologies/node-nestjs/interview-questions/api-documentation.md): 20 คำถาม, Junior - [การจัดการข้อผิดพลาด](https://sharpskill.dev/th/technologies/node-nestjs/interview-questions/error-handling.md): 20 คำถาม, Junior - [การทดสอบหน่วย (Unit Testing)](https://sharpskill.dev/th/technologies/node-nestjs/interview-questions/testing-unit.md): 20 คำถาม, Junior - [การจัดตารางงาน](https://sharpskill.dev/th/technologies/node-nestjs/interview-questions/scheduling-cron.md): 15 คำถาม, Junior - [Module และ DI ของ NestJS](https://sharpskill.dev/th/technologies/node-nestjs/interview-questions/nestjs-modules-di.md): 20 คำถาม, Mid-Level - [การกำหนดค่าและการจัดการสภาพแวดล้อม](https://sharpskill.dev/th/technologies/node-nestjs/interview-questions/configuration-environment.md): 20 คำถาม, Mid-Level - [การยืนยันตัวตนด้วย JWT](https://sharpskill.dev/th/technologies/node-nestjs/interview-questions/authentication-jwt.md): 25 คำถาม, Mid-Level - [การให้สิทธิ์และ RBAC](https://sharpskill.dev/th/technologies/node-nestjs/interview-questions/authorization-rbac.md): 20 คำถาม, Mid-Level - [ฐานข้อมูลด้วย TypeORM](https://sharpskill.dev/th/technologies/node-nestjs/interview-questions/database-typeorm.md): 30 คำถาม, Mid-Level - [Prisma ORM](https://sharpskill.dev/th/technologies/node-nestjs/interview-questions/prisma-orm.md): 25 คำถาม, Mid-Level - [Middleware และ Interceptor](https://sharpskill.dev/th/technologies/node-nestjs/interview-questions/middleware-interceptors.md): 20 คำถาม, Mid-Level - [การอัปโหลดไฟล์](https://sharpskill.dev/th/technologies/node-nestjs/interview-questions/file-upload.md): 15 คำถาม, Mid-Level - [WebSockets](https://sharpskill.dev/th/technologies/node-nestjs/interview-questions/websockets.md): 20 คำถาม, Mid-Level - [GraphQL กับ NestJS](https://sharpskill.dev/th/technologies/node-nestjs/interview-questions/graphql-basics.md): 25 คำถาม, Mid-Level - [การทดสอบแบบ End-to-End](https://sharpskill.dev/th/technologies/node-nestjs/interview-questions/testing-e2e.md): 20 คำถาม, Mid-Level - [การแคชด้วย Redis](https://sharpskill.dev/th/technologies/node-nestjs/interview-questions/caching-redis.md): 20 คำถาม, Mid-Level - [คิวด้วย Bull](https://sharpskill.dev/th/technologies/node-nestjs/interview-questions/queues-bull.md): 20 คำถาม, Mid-Level - [DevOps, Logging และ CI/CD](https://sharpskill.dev/th/technologies/node-nestjs/interview-questions/logging-monitoring.md): 25 คำถาม, Mid-Level - [Docker และ Containerization](https://sharpskill.dev/th/technologies/node-nestjs/interview-questions/docker-containerization.md): 25 คำถาม, Mid-Level - [ไมโครเซอร์วิส](https://sharpskill.dev/th/technologies/node-nestjs/interview-questions/microservices.md): 30 คำถาม, Senior - [แนวทางปฏิบัติที่ดีที่สุดด้านความปลอดภัย](https://sharpskill.dev/th/technologies/node-nestjs/interview-questions/security-best-practices.md): 25 คำถาม, Senior - [ประสิทธิภาพและการ Deploy บน Cloud](https://sharpskill.dev/th/technologies/node-nestjs/interview-questions/performance-optimization.md): 30 คำถาม, Senior --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/th/technologies/node-nestjs/interview-questions/nodejs-core-apis