Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

474
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!