Should I worry about the "missing semicolon" in JSLint?

I have the following:

$.ajaxSetup({beforeSend:function(a){a.setRequestHeader("Accept","text/javascript")},cache:false});

JSLint tells me: β€œProblem with line symbol 1 83: Missing semicolon”

Do you agree? I added it, but when I use the YUI compressor, does it delete it?

thank

+3
source share
5 answers

JSLint will hurt your feelings.

- Douglas Crockford

And in 90% of cases it does nothing, it can complain about the missing semicolon, but the code still works fine, since it is technically not needed in this position, so the YUI compressor removes it to save the byte.

+5
source

JSLint , . .

+4

( / ).

,

function a() {

   return // <-- semi colon is inserted here, terminating the line.
     {
         abc: '???'
     }
}

alert(a()); // undefined

BSD KNF.

, - , .

Update

Pst (), ASI - return , . , , ASI - \n a ;, .

ASI, PITA.

var a = function(b) {

    b.call();  

};

(function() {
    c = 'hello',
    a

    (function() {
        alert('hello')  
    })

})();

jsFiddle.

( a )?

- var, , . ( :)).

​​ a() .

+3

javascript, jslint javascript. .

0

JSLint

$.ajaxSetup({beforeSend:function(a){a.setRequestHeader("Accept","text/javascript");},cache:false});

: ; setRequestHeader.

0
source

Source: https://habr.com/ru/post/1779546/


All Articles