For loop through custom field in JavaScript
You could output the numbers in a data attribute on a wrapping HTML element:

{% set numbers = '' %} 

{% for stats in entry.statsPanels %}
    {% set numbers = numbers ~ stats.statsNumber %}
    {% if not loop.last %}
        {% set numbers = numbers ~ ',' %}
    {% endif %}
{% endfor %}

&lt;div class="myComponent" data-numbers="{{ numbers }}"&gt;
...
&lt;/div&gt;


Then you can read them in your JavaScript file:

var endCounterVar = $('.myComponent').data('numbers');

if (endCounterVar.length) {
    endCounterVar = endCounterVar.split(',');
}


This might not be the cleanest/shortest way to achieve this in Twig, mind you!