title: Get List of Supported Currencies
body: <p>Other than just guessing (like I've done below), is there a more direct and efficient way of <strong>reflectively</strong> retrieving a list of all currencies supported by your JavaScript environment?</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function getSupportedCurrencies() {
    function $(amount, currency) {
      let locale = 'en-US';
      let options = {
        style: 'currency',
        currency: currency,
        currencyDisplay: "name"
      };
      return Intl.NumberFormat(locale, options).format(amount);
    }
    const getAllPossibleThreeLetterWords = () =&gt; {
      const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
      const arr = [];
      let text = '';
      for (let i = 0; i &lt; chars.length; i++) {
        for (let x = 0; x &lt; chars.length; x++) {
          for (let j = 0; j &lt; chars.length; j++) {
            text += chars[i];
            text += chars[x];
            text += chars[j];
            arr.push(text);
            text = '';
          }
        }
      }
      return arr;
    };
    let ary = getAllPossibleThreeLetterWords();
    let currencies = [];
    const rx = /(?&lt;= ).+/; // This line doesn't work in Firefox versions older than version 78 due to bug 1225665: https://bugzilla.mozilla.org/show_bug.cgi?id=1225665
    ary.forEach((cur) =&gt; {
      let output = $(0, cur).trim();
      if (output.replace(/^[^ ]+ /, '') !== cur) {
        let obj = {};
        obj.code = cur;
        obj.name = output.match(rx)[0];
        currencies.push(obj);
      }
    });
    return currencies;
  }
  console.log(getSupportedCurrencies());</code></pre>
  </div>
  </div>
  </p>