I've seen a triple semicolon in a few expressions here and there.
Does it have any logical effect?The closest thing I've seen for an explanation is that it tells the Dean Edwards compressor to ignore tha开发者_Python百科t line.
;;; var someVar = 'Rebel';
It makes people ask questions on StackOverflow.
Other than that, it does nothing.
Nothing. Absolutely nothing.
Three semicolons, ten semicolons, a hundred semicolons, they all get interpreted to the same result: nothing.
Lines starting with three semicolons are there for debug code: it indicates that those lines should not appear in the production environment. The Javascript is run through a compressor or some other algorithm that removes ;;;
lines when creating the optimized JS file.
;;; console.log("only run this line when debugging!");
As indicated above, three semicolons actually does nothing in Javascript: it just ends three consecutive empty statements. If an actual comment was used
// console.log("only run this line when debugging!");
then you'd have to go in and manually remove all comments when you wanted to enter debug mode, and then go in and put them back when you were done. The other solution is to create a DEBUG
variable and wrap all debug lines in a condition:
var DEBUG = true;
if(DEBUG){
console.log("only run this line when debugging!");
}
but this is a little cumbersome and actually adds unneeded code to your Javascript document. Of course you could run the JS through a compressor to remove the DEBUG
conditions, but at that point you might as well just use the ;;;
method, which is simpler.
See this question for a real life example of this. BTW, I think the syntax comes from emacs.
Ends an empty statement 3 times.
They are empty statements and have no effect. It is possible that the interpreter or compiler will remove them unless a statement is required by the syntax.
精彩评论