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 trial

JavaScript Gulp Basics Gulp your JavaScript Workflow Using Third Party Gulp Libraries

Tony Brackins
Tony Brackins
28,766 Points

var with require('gulp') but not with require ('gulp-concat')

Wondering why in this video we're using var with gulp, but not with concat.

1 Answer

Zac Mackey
Zac Mackey
11,392 Points

Hi Tony!

The reason why 'var' isn't declared before the variable concat is because there is a comma after the variable assignment, opposed to a semi-colon.

 var gulp = require('gulp'),
    concat = require('gulp-concat');

Basically, by using a comma to separate the two variable declarations and assignments you don't need to state var for each variable.

Had the var gulp = require('gulp') declaration and assignment ended with a semi-colon then you would need to add var before concat as well to keep the scope correct.

var gulp = require('gulp');
var concat = require('gulp-concat');

I may not be explaining this very well, but I hope that clears it up.

Tony Brackins
Tony Brackins
28,766 Points

oh gotcha! Didn't see the comma. Makes perfect sense now!