( FeriX | 2023. 12. 18., h – 14:16 )

Ezt nem így kell csinálni. A "dataset" az esetedben kulcsfontosságú:

 

document.addEventListener('DOMContentLoaded', function() {
  var spanok = document.querySelectorAll('[data-function]')

  spanok.forEach(function(span) {
    var scriptem = span.dataset.function

    var paramétereim = Object
      .keys(span.dataset)
      .filter(key => key.startsWith('param'))
      .map(key => span.dataset[key])

      if (typeof window[scriptem] === 'function') {
        window[scriptem].apply(undefined, paramétereim)
    }
  });
});

 

Valami ilyesmi.