title: Cannot read property 'toLocaleString' of undefined
body: <p>I have a Tampermonkey script that adds some information to a browser-based game. I use a simple piece of code to add thousand separators to numbers based on the players' locales:</p>
  
  <pre><code>function nThousand(x) {
      return x.toLocaleString();
  }
  </code></pre>
  
  <p>This function is used in a lot of the code, for example:</p>
  
  <pre><code>$("#CustomStats" + stat).html(
  "&lt;b&gt;" + texts[lang].stat_points_need + ":&lt;/b&gt; " + nThousand(remainingPoints) + "&lt;br /&gt;" +
  "&lt;b&gt;" + texts[lang].money_need + ": &lt;/b&gt;" + nThousand(remainingMoney) + "&lt;br /&gt;" +
  "&lt;b&gt;" + texts[lang].money_spent + ": &lt;/b&gt;" + nThousand(currentMoney) + "&lt;br /&gt;&lt;br /&gt;" +
  "&lt;b&gt;" + texts[lang].bought_points + ": &lt;/b&gt;" + nThousand(boughtPoints) + "&lt;br /&gt;" +
  "&lt;b&gt;" + texts[lang].equipment_points + ": &lt;/b&gt;" + nThousand(itemPoints) + "&lt;br /&gt;" +
  "&lt;b&gt;" + texts[lang].points_from_level + ": &lt;/b&gt;" + nThousand(skillPoints) + "&lt;br /&gt;"
  );
  </code></pre>
  
  <p>This has worked perfectly for ages, but for some reason on one particular platform the game runs on, the script now refuses to load and gives the following error message:</p>
  
  <blockquote>
    <p>Cannot read property 'toLocaleString' of undefined</p>
  </blockquote>
  
  <p>I've gone back several dozen versions to make sure it wasn't something I added or changed recently, and I honestly don't even know where I would start solving this issue. The function only runs when there is a value to be localised and it's only on one specific platform the game runs on that it does this.</p>
  
  <p>My question: what could be causing this and how would I go about solving this problem?</p>