Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Double semicolons syntax in javascript

Tags:

javascript

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 (taken from CDNJS):

(function($, undefined) {

;;

var defaults = {

    // display
    defaultView: 'month',
    aspectRatio: 1.35,
    header: {
        left: 'title',
        center: '',
        right: 'today prev,next'
    },
    weekends: true,
    weekNumbers: false,
    weekNumberCalculation: 'iso',
    weekNumberTitle: 'W',   
    allDayDefault: true,
    ignoreTimezone: true,

    // event ajax
    lazyFetching: true,
    startParam: 'start',
    endParam: 'end',

    // time formats
    titleFormat: {
        month: 'MMMM yyyy',
        week: "MMM d[ yyyy]{ '—'[ MMM] d yyyy}",
        day: 'dddd, MMM d, yyyy'
    },
    columnFormat: {
        month: 'ddd',
        week: 'ddd M/d',
        day: 'dddd M/d'
    },
    timeFormat: { // for event elements
        '': 'h(:mm)t' // default
    },

    // locale
    isRTL: false,
    firstDay: 0,
    monthNames: ['January','February','March','April','May','June','July','August','September','October','November','December'],
    monthNamesShort: ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],
    dayNames: ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'],
    dayNamesShort: ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'],
    buttonText: {
        prev: "<span class='fc-text-arrow'>&lsaquo;</span>",
        next: "<span class='fc-text-arrow'>&rsaquo;</span>",
        prevYear: "<span class='fc-text-arrow'>&laquo;</span>",
        nextYear: "<span class='fc-text-arrow'>&raquo;</span>",
        today: 'today',
        month: 'month',
        week: 'week',
        day: 'day'
    },

    // jquery-ui theming
    theme: false,
    buttonIcons: {
        prev: 'circle-triangle-w',
        next: 'circle-triangle-e'
    },

    //selectable: false,
    unselectAuto: true,

    dropAccept: '*',

    handleWindowResize: true

};

...
}
like image 643
user3157797 Avatar asked Jan 03 '14 15:01

user3157797


1 Answers

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).

like image 123
nothingisnecessary Avatar answered Oct 15 '22 02:10

nothingisnecessary