Saturday, May 19, 2012

Firebug Error --> Variable out of range

Hello friends,

I have thought of sharing this very important piece of info with you guys today .

Its mainly about this error which you might get while debugging  your web application in Firebug in mozilla :

"Varibale out of range (30 of 292)" or something like that.

Do understand that it is mainly because your variable is getting called somewhere else before its actual place where it must be called.

This mainly happens in a scenario where you have getters and setters for this variable and you are returning a value.

In such a case, let me give an example here :

var kVaraiable; // my variable

get kVariable();
set kVariable()
{
    return something;
}

Here , if you see kVariable out of range, then go ahead and take a peek in your firebug console and give special notice to the response and JSON part. You will see that some variable is giving an undefined value there.

Hence, to fix this you need to prevent the setter from returning anything , so you do this :

set kVariable()
{
    if(kVariable != undefined)  // this will prevent the variable from returning anything if it gets called          unexpectedly .
    return something;

}


ADIOS Freinds,
Think Free .


2 comments:

  1. But let us say that in some scenario, we are doing something with this return value...

    Won't it cause a null reference error at that calling point if you simply choose NOT to return anything from the function?

    ReplyDelete
    Replies
    1. Of course we are using this function, but , let us consider a huge assembly of of js files, you are working on some of them , others are working on the remaining ones. Now, that function has been created by you with a specific scenario in mind .

      Others don't know that, so , probably by mistake they might call this one at a certain point of their code, which they are not supposed to do. That in turn might screw up the whole functionality and nothing will get processed.

      Just saying, that in such a scenario, it will be wise to use that fix, as it will get your application working, since you will only return something for that scenario and you know that this scenario is supposed to return something. This will then cause the other guy to think that he must not call your variable for it used specifically by you to handle a specific scenario and he will adjust his code as such .

      Delete