title: GulpUglifyError: unable to minify JavaScript Caused by: SyntaxError: Unexpected token name «k», expected punc «;»
body: <p>I am getting some strange error, but in order to suppress these error I have to change everything where I am getting error?   </p>
  
  <pre><code>//gulp file code
  var fs = require('fs');
  var path = require('path');`enter code here`
  var merge = require('merge-stream');
  var gulp = require('gulp');
  var concat = require('gulp-concat');
  var rename = require('gulp-rename');
  var uglify = require('gulp-uglify');
  var sourcemaps = require('gulp-sourcemaps');
  var gutil = require('gulp-util');
  
  
  
  gulp.task('css',function()
  {
  
  return gulp.src(['assets/css/*.css'])
      .pipe(sourcemaps.init())
  
      .pipe(sourcemaps.write())
      .pipe(uglify())
      .on('error', function (err) { gutil.log(gutil.colors.red('[Error]'), err.toString()); })
      .pipe(concat('all.css'))
      .pipe(gulp.dest('build/css'))
  
  })
  gulp.task('js',function()
  {
  
  return gulp.src(['shared/*.js','controller/*.js','directives/*.js','services/*.js'])
      .pipe(sourcemaps.init())
  
      .pipe(sourcemaps.write())
      .pipe(uglify())
      .on('error', function (err) { gutil.log(gutil.colors.red('[Error]'), err.toString()); })
      .pipe(concat('all.js'))
      .pipe(gulp.dest('build/js'))
  
  })
  
  gulp.task('default', ['css','js']);
  </code></pre>
  
  <p>I tried to find the solution online, but no luck</p>
  
  <pre><code>for (let k = 0; k &lt; $scope.allCollctedTags.length; k++) 
  {
   $scope.customtags.push($scope.allCollctedTags[k].text);
  }
  </code></pre>
  
  <p>but if I replace let with var then this error removed now next error come for the following code:</p>
  
  <pre><code>$scope.multipleImages.push(...response.data.result.imageName);
  but if i write it as below then this error disappear
  $scope.multipleImages.push(response.data.result.imageName);
  
  also if i use underscore js then also it give me error 
  let temparray = _.difference($scope.multipleImages,$scope.extractedImagesBrowse);
  </code></pre>
  
  <p>Now what to do, I can do these things in one or two files but for the whole project I cannot do it.</p>