Double semicolons syntax in javascript

前端 未结 2 788
抹茶落季
抹茶落季 2021-01-12 06:54

Can someone tell me what double semicolons (;;) in javascript means? I see them in fullcalendar.js.

Thanks.

Here\'s a snippet of the fullcalendar.js code (ta

相关标签:
2条回答
  • 2021-01-12 07:09
    Empty “for” loop
    

    for(;;){...} is the same as saying while(1){...}

    for(;;) jumps out to mean "infinite loop" more readily than while(1)

    facebook's AJAX responses all start with an empty for loop.

    0 讨论(0)
  • 2021-01-12 07:24

    The double semicolons ;; has nothing to do with a for loop in the case of fullcalendar.js (which is now on github).

    There is no value to the parsing or execution of the code itself (it is basically innocuous); rather the author has used ;; merely as a sentinel to separate logical chunks of code. It was a weird and esoteric choice to do this, but as it turns out it is very helpful to use CTRL-F to search for ;; to jump from one section to another (for example, the class definitions appear to be separated in this way).

    The author could have used comments, for example:

    /* ;; */

    or

    /* CLASSDEF */

    etc., but he didn't.

    Also confirmed: the JavaScript minifiers I tested remove the ;; so definitely not critical to the code, and not helpful as a sentinel when searching minified code. (but neither are comments because they are stripped out).

    0 讨论(0)
提交回复
热议问题