Created
April 20, 2012 14:12
-
-
Save Ikke/2428988 to your computer and use it in GitHub Desktop.
Set object
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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