2014-10-08 64 views
-1

24:42我今天跨越:「check:」在for循環前面是什麼意思?

check: for (var i = 0; i < versionList.length; i++) { 
    var curVersion = versionList[i]; 

    // find the critical ranges this version is in (the ranges only it can support) 
    var ranges = getCriticalRanges(target.name, curVersion); 

    // if this version satisfies all of the ranges, then we can replace with this version 
    for (var j = 0; j < ranges.length; j++) { 
    if (!semver.match(ranges[j], lookup.version)) 
     continue check; 
    } 

    // if the version is not equal to our target, deprecate the old version 
    if (lookup.version != curVersion) { 
    var oldName = lookup.name + '@' + curVersion; 

    if (ranges.length) { 
     useExisting = true; 
     ui.log('info', (nodeSemver.gt(lookup.version, curVersion) ? 'Upgrading' : 'Downgrading') + ' `' + oldName + '` to `' + lookup.version + '`'); 
    } 
    else { 
     // wasn't critical anyway - just remove 
     deprecated.push(oldName); 
    } 

    // remove all traces, but leave the package in the file system for cache value 
    delete config.depMap[oldName]; 
    versionList.splice(i--, 1); 
    } 
} 

我從來沒有見過,在之前的JavaScript。我在這裏找到它:https://github.com/jspm/jspm-cli/blob/0.8.0-beta.2/lib/core.js#L328

那是什麼?

+1

這是一個[標籤](https://developer.mozilla.org/fr/docs/JavaScript/Reference/Instructions/label) – 2014-10-08 07:18:55

回答

4

這是一個labelcontinue跳轉到。

示例(從鏈接的頁面):

loop1: 
for (i = 0; i < 3; i++) {  //The first for statement is labeled "loop1" 
    loop2: 
    for (j = 0; j < 3; j++) { //The second for statement is labeled "loop2" 
     if (i == 1 && j == 1) { 
     continue loop1; 
     } 
     console.log("i = " + i + ", j = " + j); 
    } 
} 

,但考慮到在同一頁面上的警告:

避免使用標籤

標籤沒有在JavaScript,因爲很常用他們讓 程序難以閱讀和理解。

相關問題