javascriptjslint

Unexpected token operator «=», expected punc «,»


i am getting the following error

Parse error: Unexpected token operator «=», expected punc «,» Line 159, column 26

This is my code

  function fitBounds(type="all", shape=null) {
    var bounds = new google.maps.LatLngBounds();

    if ( type == "all" ){
      if ((circles.length > 0) | (polygons.length > 0)){
        $.each(circles, function(index, circle){
          bounds.union(circle.getBounds());
        });
        $.each(polygons, function(index, polygon){
          polygon.getPath().getArray().forEach(function(latLng){
            bounds.extend(latLng);
          });
        });
      }
    }
    else if ( (type == "single") && (shape != null) ) {
      if (shape.type == google.maps.drawing.OverlayType.MARKER) {
        marker_index = markers.indexOf(shape);
        bounds.union(circles[marker_index].getBounds());
      }
      else {
        shape.getPath().getArray().forEach(function(latLng){
          bounds.extend(latLng);
        });
      }
    }

    if (bounds.isEmpty() != true)
    {
      map.fitBounds(bounds);
    }
  }

Solution

  • You are trying to use Default parameters, which are a bleeding edge feature of JavaScript with limited support.

    JS Lint rejects them unless you turn on the ES6 option.