2

I came across this while learning about child processes:

const {spawn} = require('child_process');

My question is, what is the difference between the above and this:

const spawn = require('child_process');
fedesc
  • 2,270
  • 2
  • 18
  • 34
TejasOS
  • 409
  • 2
  • 11

1 Answers1

0

The 1st extracts spawn variable from inside child_proccess. This only unpack value of spawn from child_proccess instead of the whole module.

The 2nd sets spawn variable the entire child_process module (as a whole).

read more on Destructuring assignment

fedesc
  • 2,270
  • 2
  • 18
  • 34