1

I am getting a reference error while I try to call a object function, and that object function is calling another function.

For example:

I have a function to return an object;

function krPano(){
    return document.getElementById("krObj");
}

Now I have a object literal that contains some helper functions that I want to use. For example:

var contextMenuInfo = {

        getContextMenuCount : function(){
            return KrPano().get("contextmenu").item.count;
        }
}

So in getContextMenuCount func I am using KrPano() to get the object.

Now again there is another function where I call the getContextMenuCount function.

function showDifferentContextMenu(){

    console.log(contextMenuInfo.getContextMenuCount());

}

When I execute this function, I get reference error saying can't find variable KrPano.

9
  • 2
    Your function is declared as krPano() and you're calling it as KrPano(). Are you sure this typo isn't happening in your code? Function and variable names are case sensitive in javascript. Commented Oct 14, 2016 at 17:08
  • i am sure there is no typo in calling the fnc krPano() Commented Oct 14, 2016 at 17:10
  • Um, are you really sure? lol Commented Oct 14, 2016 at 17:10
  • i am assuming that KrPano() calling inside the contextMenuInfo is doing something wrong? Commented Oct 14, 2016 at 17:10
  • The case K vs k Commented Oct 14, 2016 at 17:11

1 Answer 1

2

Your function is defined as krPano when you're calling it as KrPano.

Do this instead (lowercase k):

return KrPano().get("contextmenu").item.count;

JavaScript is case-sensitive.

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.