0

I came across this piece of code and now I am baffled. I have never seen this outer: (line 1) and break outer; (line 8) before. Starting a statement with name + ; and referring to it later

outer: if (oldDom == null || oldDom.parentNode !== parentDom) {
    parentDom.appendChild(newDom);
} else {
    sibDom = oldDom;
    j = 0;
    while ((sibDom = sibDom.nextSibling) && j++ < oldChildrenLength / 2) {
        if (sibDom === newDom) {
            break outer;
        }
    }
    parentDom.insertBefore(newDom, oldDom);
}

can anyone explain what this is called and what it is?

melpomene
  • 81,915
  • 7
  • 76
  • 137
Lukas
  • 8,712
  • 11
  • 63
  • 107
  • 1
    https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/label – melpomene Apr 13 '19 at 23:43
  • 1
    Thanks for the answer. I wonder why people think this is a duplicate. The other guy obviously knew what this is and wondered if it is legit to use. – Lukas Apr 14 '19 at 18:49
  • Yeah, I for one voted to reopen this question (and either find a better dupe or leave it open). – melpomene Apr 14 '19 at 23:28

0 Answers0