Skip to content

Instantly share code, notes, and snippets.

@Ikke
Created April 20, 2012 14:12
Show Gist options
  • Save Ikke/2428988 to your computer and use it in GitHub Desktop.
Save Ikke/2428988 to your computer and use it in GitHub Desktop.
Set object
var Set = function() {
this.items = {};
this.add = function(key) {
this.items[key] = true;
}
this.exists = function(key) {
return this.items.hasOwnProperty(key);
}
this.as_array = function() {
var keys = [];
console.log(this);
jQuery.each(this.items, function(key){
keys.push(key);
});
return keys;
}
this.remove = function(key) {
delete this.items[key];
}
return this;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment