Saturday, 15 February 2014

Array inside a Javascript Object? -


I have tried to see that this is possible, but I could not find my answer.

I am trying to do the following:

  var defaults = {'background-color': '# 000', color: '#fff', weekdays : {['Suraj', 'Mon', 'Tu', 'With', 'Tha', 'Venus', 'Saturn']}};  

This only gives an error, and I ({...}) and [... ...]] I want to be able to use something like a few days to use:

  defaults.weekdays [0];  

Is this possible?

Kill the braces.

  var defaults = {backgroundcolor: '# 000', color: '#fff', weekdays: ['sun', 'mon', 'tue', 'wed', 'thu' , 'Venus', 'Saturn']};  

No comments:

Post a Comment