意外的令牌运算符«=»,预期的标点«,» [英] Unexpected token operator «=», expected punc «,»

查看:71
本文介绍了意外的令牌运算符«=»,预期的标点«,»的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到以下错误

解析错误:意外的令牌运算符«=»,预期的标点«,»行 159,第26列

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

这是我的代码

  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);
    }
  }

推荐答案

您正尝试使用有限的支持.

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

JS Lint拒绝它们,除非您打开ES6选项.

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

这篇关于意外的令牌运算符«=»,预期的标点«,»的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆