I have the following code and was wondering why I am not allowed to create another object within another.
CODE
//Object initializer
var shoe = {
size: 10,
make: var maketype = {
this.brand: "rebook"
},
availability: "now"
}
You can do that very well. It’s the extra
var maketype =that is illegal (and alsothisas part of a property name).This works:
If you want to retain a separate reference to the
make, you can do it like this: