Skip to main content

Ivan Teoh

Something personal yet public

167-exercise41.js

(Source)

1
2
3
4
5
6
7
8
var cat = {}; // a 'set' of names
cat['Red Lion'] = {'colour': 'grey', 'size': 46}; // a name is added to this set
cat['Doctor Hobbles'] = {'colour': 'white', 'size': 15};
cat['Little Iroquois'] = {'colour': 'yellow', 'size': 30};
delete cat['Doctor Hobbles']; // a name is removed from this set
if ('Red Lion' in cat) { // check whether a name occurs in this set.
    alert('you have "Red Lion" cat.');
}