You can build your object like this:
var availability = {"someTshirt":
{
'small': 'available',
'med' : 'available',
'large' : 'not available'
}
};
Then you can access this object with:
availability.someTshirt.small
>>> 'available'
availability.someTshirt.large
>>> 'not available'
However I'd recommend you to use booleans instead of strings, which are easier to manipulate. You can still change the display string later:
var availability = {"someTshirt":
{
'small': true,
'med' : true,
'large' : false
}
};
if (availability.someTshirt.small) {
console.log('available');
}
>>> 'available'
[edit]
Response to the comment:
If you want to create your objects dynamically, you can do the following:
var availability = {};
availability.someTshirt = {};
availability.someTshirt.small = true;
availability.someTshirt.med = true;
availability.someTshirt.large = false;
if (availability.someTshirt.small) {
console.log("available");
} else {
console.log("not available");
}
>>> 'available'
availability.someTshirt.small = false;
if (availability.someTshirt.small) {
console.log("available");
} else {
console.log("not available");
}
>>> 'not available'