Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumNodeJSchild_process spawningSingle-choice MCQ

spawn is called two ways below. What does each print and why?

const cp = require('child_process'); console.log(cp.spawnSync('echo', ['$HOME'], { encoding: 'utf8' }).stdout.trim()); console.log(cp.spawnSync('echo $HOME', { shell: true, encoding: 'utf8' }).stdout.trim());