Double semicolons syntax in javascript

前端 未结 2 786
抹茶落季
抹茶落季 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: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).

提交回复
热议问题