code: function /* 9.2.2 */$$core$$BestAvailableLocale (availableLocales, locale) {
          var
             // 1. Let candidate be locale
             candidate = locale;
  
          // 2. Repeat
          while (true) {
              // a. If availableLocales contains an element equal to candidate, then return
              // candidate.
              if ($$core$$arrIndexOf.call(availableLocales, candidate) > -1)
                  return candidate;
  
              var
                  // b. Let pos be the character index of the last occurrence of "-"
                  // (U+002D) within candidate. If that character does not occur, return
                  // undefined.
                  pos = candidate.lastIndexOf('-');
  
              if (pos < 0)
                  return;
  
              // c. If pos ≥ 2 and the character "-" occurs at index pos-2 of candidate,
              //    then decrease pos by 2.
              if (pos >= 2 && candidate.charAt(pos - 2) === '-')
                  pos -= 2;
  
              // d. Let candidate be the substring of candidate from position 0, inclusive,
              //    to position pos, exclusive.
              candidate = candidate.substring(0, pos);
          }
      }
docs: The BestAvailableLocale abstract operation compares the provided argument
  locale, which must be a String value with a structurally valid and
  canonicalized BCP 47 language tag, against the locales in availableLocales and
  returns either the longest non-empty prefix of locale that is an element of
  availableLocales, or undefined if there is no such element. It uses the
  fallback mechanism of RFC 4647, section 3.4. The following steps are taken: