1

Hi, Unable to minify because some of the codes showing error.

The error message --> Unexpected token: operator (>) (line: 4, col: 56)

var text = comment.item(i).textContent;
            var phone = '';
            if(text.match(/\d{10,11}/g)!=null){
                phone = text.match(/\d{10,11}/g).map(n => `6${n}`).join(', ');
            }

How to change some of the problem codes before minify process?

Thanks

1 Answer 1

1

Probably, your minifier doesn't support ES6 syntax.
Try to find another minifier or a new version which support ES6 syntax. By 2018, most of them should support ES6.

If it is not possible, you can make it work by getting rid of arrow function and template literal by changing this:

phone = text.match(/\d{10,11}/g).map(n => `6${n}`).join(', ');

to

phone = text.match(/\d{10,11}/g).map(function(n) { return "6" + n; }).join(', ');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.