Skip to main content Accessibility Feedback

Function.prototype.bind and Opera Mini

Last week I discovered that a few scripts that should work in Opera Mini were not. And they weren’t just failing to work. They were passing the mustard test, so important content was getting obscured with no way to access it.

The problem turned out to be with Function.prototype.bind, a late addition to the ECMAScript 5 standard that is missing from some otherwise compatible browsers (like Opera Mini). Fortunately, there’s an easy fix.

Function.prototype.bind polyfill #

The fix was as easy as dropping in a polyfill, courtesy of MDN:

if (!Function.prototype.bind) {
    Function.prototype.bind = function (oThis) {
        if (typeof this !== "function") {
            // closest thing possible to the ECMAScript 5
            // internal IsCallable function
            throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");

        var aArgs =, 1);
        var fToBind = this;
        fNOP = function () {};
        fBound = function () {
            return fToBind.apply(this instanceof fNOP && oThis ? this : oThis, aArgs.concat(;

        fNOP.prototype = this.prototype;
        fBound.prototype = new fNOP();

        return fBound;

All of my scripts that use Function.prototype.bind now include the polyfill.

🚀 Make 2018 the year you master JavaScript! My pocket guides and mini courses are short, focused, and made for beginners. You can do this!

Have any questions or comments about this post? Email me at or contact me on Twitter at @ChrisFerdinandi.

Get Daily Developer Tips