Bird
0
0

Which of the following is the correct syntax to create a SharedArrayBuffer of 16 bytes in Node.js?

easy📝 Syntax Q3 of 15
Node.js - Worker Threads
Which of the following is the correct syntax to create a SharedArrayBuffer of 16 bytes in Node.js?
Aconst sab = new SharedArrayBuffer(16);
Bconst sab = SharedArrayBuffer(16);
Cconst sab = new SharedArrayBuffer(); sab.resize(16);
Dconst sab = SharedArrayBuffer.create(16);
Step-by-Step Solution
Solution:
  1. Step 1: Recall correct constructor usage

    SharedArrayBuffer is created with the new keyword and a size in bytes as argument.
  2. Step 2: Check options for correct syntax

    Only const sab = new SharedArrayBuffer(16); uses 'new' and passes size correctly.
  3. Final Answer:

    const sab = new SharedArrayBuffer(16); -> Option A
  4. Quick Check:

    Correct constructor syntax = D [OK]
Quick Trick: Use 'new' keyword with size to create SharedArrayBuffer [OK]
Common Mistakes:
  • Omitting 'new' keyword
  • Trying to resize after creation
  • Using non-existent create method

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Node.js Quizzes