Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9178273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:30:48+00:00 2026-06-17T17:30:48+00:00

I have a class that is structured something like this function myClass () {

  • 0

I have a class that is structured something like this

function myClass () {
    this.varA = 0;
}

myClass.prototype.consts = {
    someConst : 1,
    anotherConst : 1000,
}

myClass.prototype.startIt = function () {
    window.setTimeout(this.brokenFunc.bind(this), this.consts.anotherConst);
}

myClass.prototype.brokenFunc = function () {
    this.varA += this.consts.someConst;

    window.setTimeout(this.brokenFunc.bind(this), this.consts.anotherConst); 
}

// Example call
var myObj = new myClass();
myObj.startIt();

This works fine on most Android devices — but a user running Android 2.3 has now informed me that it doesn’t work and I could reproduce the error in an emulator. First, it says TypeError: Result of expression 'this.brokenFunc.bind' [undefined] is not a function for this line (within startIt):

window.setTimeout(this.brokenFunc.bind(this), this.consts.anotherConst); 

Fair enough, I thought, and did the old var _this = this trick to get around the bind call. But now it says TypeError: Result of expression 'this.consts' [undefined] is not an object in this line

this.varA += this.consts.someConst;

And I’m a little lost. How can this piece of code not work? Especially since it works in most Android versions.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T17:30:49+00:00Added an answer on June 17, 2026 at 5:30 pm

    By default, setTimeout invokes functions with this of the global object (i.e., window, in the browser). (Side note: in strict mode, it’s undefined instead.) Thus, when you don’t use bind, the this brokenFunc is now window instead of the object that registered the timeout.

    In order to preserve the this from startIt, you’ll need to wrap your call in an anonymous function:

    myClass.prototype.startIt = function () {
        var that = this;
    
        window.setTimeout(function() {
            // call brokenFunc with the outer this
            that.brokenFunc();
        }, this.consts.anotherConst);
    }
    

    Your first error happened because the Android 2.3 browser doesn’t support the EMCAScript 5 bind function. Your second error appeared because this.consts is really window.consts, which doesn’t exist. Just wrap the call in an anonymous function that has that in its scope, and call the function from that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So right now I have an input validation method structured something like this: function
I have class that looks like this: class A { public: class variables_map vm
My class structure is something like this: var jpTWUI = function(id, connection){ this.id =
Let's say we have a class that looks like this: class A { public:
So, lets say that we have this structure: <div id='allTempLinkHolder'> <div class='tempLink'>Value</div> <div class='tempLink'>Value
I have a Class that has a private variable with a public setter/getter function:
I have code that follows this structure: class someClass { private static $pay =
I have a class that looks like: class A { public: A(); void MethodThatWillNotBeInOtherStructure();
In the data structures class that I am currently taking, we have been tasked
I have class that extend FragmentActivity in it I add fragment to layout as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.