Mottie Mottie -4 years ago 126
Javascript Question

Array inside a Javascript Object?

I've tried looking to see if this is possible, but I can't find my answer.

I'm trying to get the following to work:

var defaults = {
'background-color': '#000',
color: '#fff',
weekdays: {['sun','mon','tue','wed','thu','fri','sat']}

It just gives an error, and I've tried using
I'd like to be able to access the weekdays using somthing like:


is this possible?

Answer Source

Kill the braces.

var defaults = {
 backgroundcolor: '#000',
 color: '#fff',
 weekdays: ['sun','mon','tue','wed','thu','fri','sat']
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download