Javascript 函数导致错误

Javascript 函数导致错误,javascript,node.js,Javascript,Node.js,我创建了mapWith函数,如下所示: var mapWith=function(fn) { return funtion(list) { return Array.prototype.map.call(list,function(something){ return fn.call(this,something); }); } }; ReferenceError: list is not defined at mapWith (/

我创建了
mapWith
函数,如下所示:

  var mapWith=function(fn)
{
  return funtion(list)
  {
     return Array.prototype.map.call(list,function(something){
            return fn.call(this,something);
      });
  }
};
ReferenceError: list is not defined
at mapWith (/home/anr/Desktop/node js/mysql.js:11:17)
at Object.<anonymous> (/home/anr/Desktop/node js/mysql.js:40:21)
我在函数和数组上使用它:

 var insertLatLong=function(obj)
 {
    //inserts to db...
 }
 var inception_cities=[{lat:35.0117,lng:135.7683},
                  {lat:48.8567,lng:2.3508},
                  {lat:-4.0500,lng:39.6667},
                  {lat:33.8600,lng:151.2111},
                  {lat:34.0500,lng:118.2500}];

 var insertLocations=mapWith(insertLatLong);
 insertLocations(inception_cities);
我得到的错误如下所示:

  var mapWith=function(fn)
{
  return funtion(list)
  {
     return Array.prototype.map.call(list,function(something){
            return fn.call(this,something);
      });
  }
};
ReferenceError: list is not defined
at mapWith (/home/anr/Desktop/node js/mysql.js:11:17)
at Object.<anonymous> (/home/anr/Desktop/node js/mysql.js:40:21)
ReferenceError:未定义列表
在mapWith(/home/anr/Desktop/node js/mysql.js:11:17)
反对。(/home/anr/Desktop/node js/mysql.js:40:21)

导致此错误的原因是
返回函数(列表)
中缺少
c
。如果没有它,JavaScript会认为您想要调用名为
Function
的东西。但是你还想把
list
传递给它,因为参数是先求值的,所以你得到的是ReferenceError:它不知道
list
是什么。

你的
返回函数(list)
中缺少
c
。我脸上的表情是无价的。修复了这个问题