返回给我一个完整的功能,而不是价值

时间:2019-07-06 19:52:51

标签: javascript return-value

下面的代码在控制台中返回以下内容:

[19-07-06 12:46:55:014 PDT] undefined
[19-07-06 12:46:55:015 PDT] 
function (date) {
    var cache1 = date[0];
    var cache2 = date[1];
    this.dateKey = cache1.toString().match(/[A-Za-z]{3} [A-Za-z]{3} \d{2}/);
    this.rawTime = cache1.toString().match(/[0-99]{2}:[0-99]{2}:[0-99]{2}/);
    this.row = cache2;
    this.rawTime.toString().split(":");
    Logger.log(rTimeF);
    return rTimeF;
}

[19-07-06 12:46:55:015 PDT] NaN
[19-07-06 12:46:55:016 PDT] NaN
[19-07-06 12:46:55:016 PDT] NaN

将任务划分为子功能 在不同的步骤记录变量

 //Returns an object with dateKey,rawTime and row num
   var itemHandler =function(date){
       var cache1 = date[0]
       var cache2 = date[1]
       this.dateKey = cache1.toString().match(/[A-Za-z]{3} [A-Za-z]{3} \d{2}/);
       this.rawTime = cache1.toString().match(/[0-99]{2}:[0-99]{2}:[0-99]{2}/);
        this.row = cache2
        this.rawTime.toString().split(":")
        Logger.log(rTimeF)
        return rTimeF

  }
  var itemHandlerHelper = function(rawTime){
      Logger.log(rawTime)
      var one = (parseInt(rTimeF[1],10)*60*60)
      var two =(parseInt(rTimeF[2],10)*60)
      var three = parseInt((rTimeF))
      Logger.log(one)
      Logger.log(two)
      Logger.log(three)
  }


  var data = new rawDat("https://docs.google.com/spreadsheets/d/19hRw1hVa-PTVXFT-u_K9niRdx9Om1PNjPLOIP6isCjQ/edit#gid=0","Sheet1")
  var names = new arrayParse(data.data,6)
  var finalDate = new itemHandler(names[3])
  var rTimeF = itemHandler
  itemHandlerHelper(rTimeF)

最后三个日志(两个和三个)应该显示数字,而不是NaN

之前的日志应返回itemHandler的finaldate实例的值:rTimeF代替,它将返回整个函数

0 个答案:

没有答案