2013-05-20 1 views
1

은 어쩌면이 질문은 너무 많은 건설 아니지만 내가 왜이 구문 오류 받고 있어요 알아낼 수 보인다밝히려 모듈 패턴 구문 오류

var operations = function() { 
      function computeTotalPrice(elem) { 
       var totalpriceafter = 0; 
       $(".totalForProductNotDeleted").each(function() { 
        var pp = parseFloat($(this).html().toString().replace(",", ".")); 
        totalpriceafter += pp; 
       }); 
       return totalpriceafter; 
      }; 
      function HightLightChangedPrices(elem) { 
       elem.parent().parent().parent().find(".totalForProduct").effect("highlight"); 
       $("#totalPrice").effect("highlight"); 
      }; 
      return 
      { 
       computeTotalPrice : computeTotalPrice, 
       HightLightChangedPrices : HightLightChangedPrices/I get expected ; 
      }; 

     }; 

답변

6

return가 같은 줄에 값이 와야을 .

 return 
     { 
      computeTotalPrice : computeTotalPrice, 
      HightLightChangedPrices : HightLightChangedPrices 
     }; 

 return { 
      computeTotalPrice : computeTotalPrice, 
      HightLightChangedPrices : HightLightChangedPrices 
     }; 

문제는 "한정 제작"함께해야한다. http://es5.github.io/#x5.1.6는 자바 스크립트를 파서가 코드를보고 그 다음 inserts a semicolon하고 다음 행으로 진행 그래서,하는 return 다음 줄 끝을 첫 번째 줄을 구문 분석

If the phrase “[no LineTerminator here]” appears in the right-hand side of a production of the syntactic grammar, it indicates that the production is a restricted production: it may not be used if a LineTerminator occurs in the input stream at the indicated position. For example, the production:

ReturnStatement :
    return[no LineTerminator here]Expressionopt;

말한다. 그것은 다음 {보고 최상위 수준부터 문 블록의 시작으로 Expression Statement{로 시작할 수 없습니다 것으로 해석 : 블록 내부

ExpressionStatement :
    [lookahead ∉ { { , function }] Expression;

,

computeTotalPrice : computeTotalPrice, HightLightChangedPrices 

유효한 labelled statement 되나 성명서에는 유효하게 그 다음에 세미콜론을 묻는 이유 인 :이 올 수 없습니다.

+0

이제 알았습니다. 매우 흥미로운. –