1

Having tested an app with a webview containing a html file on a Oreo device, everything works fully. However, when using a Kitkat device (emulator), I am getting the error Possible Unhandled Promise Rejection: "Object function Object() { [native code] } has no method 'entries'".

This was ostensibly due to me having used Object.entries() in the html. Is there any way to work around this? The Browser version on the Kitkat emulator is 4.4.2-4729339 and the emulator is the default emulator on Android Studio.

2

1 Answer 1

1

To make new functions work in older browsers you can use so called Polyfills those are mostly to find on github or on Mozilla Developer Network.

What you are looking for is a Object.entries() polyfill:

if (!Object.entries)
  Object.entries = function( obj ){
    var ownProps = Object.keys( obj ),
        i = ownProps.length,
        resArray = new Array(i); // preallocate the Array
    while (i--)
      resArray[i] = [ownProps[i], obj[ownProps[i]]];

    return resArray;
  };

(Code taken from: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/entries#Polyfill)

In general I recommend you to use caniuse.com where you can check what browser supports which function.

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.