0

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.

3
  • 1
    It isn't clear from your post what your problem is. Commented Aug 20, 2009 at 16:11
  • 3
    Uuhm this should work? Only thing, you should remove the last , Only use a , to separate properties not at the end... Commented Aug 20, 2009 at 16:13
  • I second @jeffamaphone, not sure what the problem is... Commented Aug 20, 2009 at 16:15

2 Answers 2

3

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];
Sign up to request clarification or add additional context in comments.

1 Comment

Shouldn't the usage sample be: var home = menu_Controller._menuList[0]?
0

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();

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.