Bird
0
0

Which of the following is the correct syntax to spawn a process running the command ls -l?

easy📝 Syntax Q3 of 15
Node.js - Child Processes
Which of the following is the correct syntax to spawn a process running the command ls -l?
Aspawn('ls', ['-l'])
Bspawn('ls -l')
Cspawn(['ls', '-l'])
Dspawn('ls', '-l')
Step-by-Step Solution
Solution:
  1. Step 1: Understand spawn arguments

    The first argument is the command, the second is an array of arguments.

  2. Step 2: Apply correct syntax for 'ls -l'

    Use spawn('ls', ['-l']) to run ls with -l option.

  3. Final Answer:

    spawn('ls', ['-l']) -> Option A
  4. Quick Check:

    spawn syntax = command + array args [OK]
Quick Trick: spawn(command, [args]) uses array for arguments [OK]
Common Mistakes:
  • Passing all command and args as one string
  • Passing args as a string instead of array
  • Using array as first argument

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Node.js Quizzes