White Wolf
White Wolf

Reputation: 11

How to Apply polyfill in javascript

Hi i have built an app using Javascript ES6 it work well on some devices but some older devices show errors, i think it is because they do not support ES6.

below is the error from console. Note: this error only come in some devices

Uncaught SyntaxError: Unexpected token [

and here is line of code that show error

for (const [rowName, value] of Object.entries(allRows))

So kindly help me with this how i can do something to make it work on all devices. Thanks in advance.

Upvotes: -1

Views: 641

Answers (1)

Quentin
Quentin

Reputation: 943214

A polyfill provides an implementation of a function which has a native implementation in sufficiently modern environments. You can't polyfill syntax.

If you want to support JS runtimes which don't support syntax then you need to provide them with code that they do support.

You can either:

  • Write code that way in the first place
  • Transpile it using a tool like Babel.

Upvotes: 1

Related Questions