... | ... | @@ -147,31 +147,31 @@ When a function is to be invoked immediately, the entire invocation expression s |
|
|
```javascript
|
|
|
|
|
|
var collection = (function () {
|
|
|
var keys = [], values = [];
|
|
|
|
|
|
return {
|
|
|
get: function (key) {
|
|
|
var at = keys.indexOf(key);
|
|
|
if (at >= 0) {
|
|
|
return values[at];
|
|
|
}
|
|
|
},
|
|
|
set: function (key, value) {
|
|
|
var at = keys.indexOf(key);
|
|
|
if (at < 0) {
|
|
|
at = keys.length;
|
|
|
}
|
|
|
keys[at] = key;
|
|
|
values[at] = value;
|
|
|
},
|
|
|
remove: function (key) {
|
|
|
var at = keys.indexOf(key);
|
|
|
if (at >= 0) {
|
|
|
keys.splice(at, 1);
|
|
|
values.splice(at, 1);
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
var keys = [], values = [];
|
|
|
|
|
|
return {
|
|
|
get: function (key) {
|
|
|
var at = keys.indexOf(key);
|
|
|
if (at >= 0) {
|
|
|
return values[at];
|
|
|
}
|
|
|
},
|
|
|
set: function (key, value) {
|
|
|
var at = keys.indexOf(key);
|
|
|
if (at < 0) {
|
|
|
at = keys.length;
|
|
|
}
|
|
|
keys[at] = key;
|
|
|
values[at] = value;
|
|
|
},
|
|
|
remove: function (key) {
|
|
|
var at = keys.indexOf(key);
|
|
|
if (at >= 0) {
|
|
|
keys.splice(at, 1);
|
|
|
values.splice(at, 1);
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
}());
|
|
|
```
|
|
|
|
... | ... | |