Friday, 2 September 2016

I/chromium: [INFO:CONSOLE(5)] "TypeError: Object has no method 'startsWith', android wrapper app do not support javascript String startsWith function

I/chromium: [INFO:CONSOLE(5)] "TypeError: Object has no method 'startsWith',

if you see above issue, that means:

android wrapper app do not support javascript String startsWith function


Below code can solve this issue.: (put it into your js, any please before you want to call "startsWith")

if (typeof String.prototype.startsWith != 'function') {
    // see below for better implementation!
    String.prototype.startsWith = function (str){
        return this.indexOf(str) === 0;
    };
}

No comments:

Post a comment