Forum Discussion

Novari-QA's avatar
Novari-QA
Frequent Contributor
8 years ago

Object functions returning Object, Javascript doesn't understand the type.

I have an object that holds multiple sub objects. These objects can be functions or objects. See example below.

var menu = {
  Parent: {
    Child: function() { 
      Aliases.browser.pageDashboard_PhysOffice.menuMain.HoverMouse(); 
      return Aliases.browser.pageDashboard_PhysOffice.menuMain_Main; 
    }
}


When trying to get the object above, javascript doesn't understand what I am trying to return. It doesn't crash, the code just won't work when trying to call methods based on the returned object. See below

function foo()
{
  menu.Parent.Child.Click();
}


However the code below will work:

var menu = {
  Parent: {
    Child: Aliases.browser.pageDashboard_PhysOffice.menuMain_Main; 
}

function foo() {
Aliases.browser.pageDashboard_PhysOffice.menuMain.HoverMouse();
menu.Parent.Child.Click();
}



Why is it that the function returning the value won't work, but the an object that equals the value will work.