Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialChristopher Debove
Courses Plus Student 18,373 PointsCould have use destructuring
In the video when we get the arguments from command line. Couldn't we not have use the destructuring?
const [,, ...users] = process.argv
in place of
const users = process.argv.slice(2);
3 Answers
Iain Simmons
Treehouse Moderator 32,305 PointsYes, but I don't think destructuring was available in Node when this video was first made.
Christopher Debove
Courses Plus Student 18,373 PointsOw ok ! Thanks for the answer. Should have look at this.
nico dev
20,364 PointsElegant solution, though!
Kenneth Kim
3,795 PointsHi, can anyone please explain what "const [,, ...users] = process.argv" does as mention by Christopher? Is this a new syntax in ES2015? I'm not quite familiar with it yet. Thanks
Christopher Debove
Courses Plus Student 18,373 PointsYeah it is a new syntax of ES2015.
let [a, b, c] = [1, 2, 3]; // a = 1, b = 2, c = 3
let [a,, b] = [1, 2, 3]; // a = 1, b = 3