【发布时间】:2014-09-04 05:20:09
【问题描述】:
我在 Grunt 的 JSHint 上有一个错误,它大致如下:
line 48 col 23 Expected '===' and instead saw '=='.
使用 '===' 会破坏代码。
我在 Google 附近,显然禁用此选项的选项已损坏(使用截至 2014 年 9 月 4 日的最新版本)
我的代码是这样的:
$scope.getStationById = function(stationId)
{
var parsedId = stationId,
foundStation;
angular.forEach($scope.stations, function(station)
{
if(station.id == parsedId)
{
foundStation = station;
}
});
return foundStation;
};
关于如何消除这个烦人的错误有什么建议吗?
编辑
控制台日志:
console.log(station.id + " | " + parsedId);
生产:
1 | 1
3 | 1
5 | 1
【问题讨论】:
-
检查两个操作数的类型。它们不能相同。
-
添加以下日志语句并告诉输出是什么,console.log(typeof station.id);控制台.log(类型 parseId)。我认为一个是字符串,另一个是数字
标签: javascript angularjs gruntjs jshint