Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

475
Visualizações
Error in GTM: Computed property.ECMASCRIPT_2015 mode or better: computed property

I have the following function I want to run within Google Tag Manager but I am getting the following error:

This language feature is only supported for ECMASCRIPT_2015 mode or better: computed property.

Below is the function I am trying to run. How would I alter this to work with GTM? Thanks

var compactObject = function(data) {
  if (typeof data !== 'object') {
    return data;
  }

  return Object.keys(data).reduce(function(accumulator, key) {
    var isObject = typeof data[key] === 'object';
    var value = isObject ? compactObject(data[key]) : data[key];
    var isEmptyObject = isObject && !Object.keys(value).length;
    if (value === undefined || isEmptyObject) {
      return accumulator;
    }

    return Object.assign(accumulator, {[key]: value});
  }, {});
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You main question appears to be:

How can I re-write {[key]: value} so that it is supported in older versions of JS

You can re-write the computed property syntax using the longer (legacy) version

var obj = {};
obj[key] = value;

return Object.assign(accumulator, obj);
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda