The spawn() function is used to create a new process and launch it using the command line. What it does is that it creates a node module on the processor. Node.js invokes this method when the child processes return data.
The following is the syntax for the spawn() method:
child_process.spawn(command[, args][, options])
Coming to the fork() method, it can be considered as an instance of the already existing spawn() method. Spawning ensures that there is more than one active worker node to handle tasks at any given point in time.
The following is the syntax for the fork() method:
child_process.fork(modulePath[, args][, options])
If you are looking forward to becoming proficient in Angular.js, then make sure to check out Intellipaat’s latest offerings for the Angular JS Course.