有人能告诉我
javascript中的双分号(;;)是什么意思吗?我在fullcalendar.js中看到它们.
谢谢.
这是fullcalendar.js代码的片段(取自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','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'>‹</span>",next: "<span class='fc-text-arrow'>›</span>",prevYear: "<span class='fc-text-arrow'>«</span>",nextYear: "<span class='fc-text-arrow'>»</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 }; ... }
解决方法
双分号;;在fullcalendar.js(即
now on github)的情况下,与for循环无关.
解析或执行代码本身没有任何价值(它基本上是无害的);相反,作者使用过;;仅作为分离逻辑块代码的哨兵.这样做是一个奇怪而深奥的选择,但事实证明使用CTRL-F搜索是非常有帮助的;从一个部分跳到另一个部分(例如,类定义似乎以这种方式分开).
作者本可以使用评论,例如:
/ * ;; * /
要么
/ * CLASSDEF * /
等,但他没有.
同时确认:我测试的JavaScript minifiers删除了;;所以绝对不是代码的关键,并且在搜索缩小代码时没有作为哨兵的帮助. (但是评论都没有,因为它们被删除了).