views:

49

answers:

2

Hi, I'm localizing a menu and I want to assign a declared array to an object property in that way:

var menuListLocal=["Home","Play","Options","Exit"];

var menu_Controller={
 _menuList: menuListLocal,
 // .... //
}

Sorry if it is too obvious.

Thanks.

+2  A: 

What you have should work, keeping in mind ropstah's comment.

var menuListLocal=["Home","Play","Options","Exit"];

var menu_Controller={
 _menuList: menuListLocal,
 _other: 'Something'
};

Usage sample:

var home = menuListLocal._menuList[0];
John Fisher
A: 

Strange that it's not working. If John's answer doesn't clear it up for you, try explicitly setting it in an init() method on your menu_Controller:

var menuListLocal=["Home","Play","Options","Exit"];

var menu_Controller={
   _menuList: null,

   init : function (){
       menu_Controller._menuList = menuListLocal;
   }

}
menu_Controller.init();
Pat