In several JavaScript libraries I saw this notation at the very beginning:
/**
* Library XYZ
*/
;(function () {
// ... and so on
While I'm perfectly comfortable with the "immediately executed function" syntax
(function(){...})()
I was wondering what the leading semicolon is for. All I could come up with is that it is an insurance. That is, if the library is embedded in other, buggy code, it serves as an "the last statement ends here at the latest" kind of speed bump.
Has it got any other functionality?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…