Created
June 4, 2010 21:55
-
-
Save orlandov/425992 to your computer and use it in GitHub Desktop.
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
| sys = require('sys'); | |
| puts = sys.puts; | |
| inspect = sys.inspect; | |
| Shazbot = function (args) { | |
| this.objectHash = {}; | |
| } | |
| Shazbot.prototype.myFunction = function(id) { | |
| puts("\nUsing id " + id + "\n------------------"); | |
| var objstr = '{"id":"'+id+'"}'; | |
| var obj = JSON.parse(objstr); | |
| this.objectHash[id] = {}; | |
| puts("Are the two ids equal? " + (obj.id == id)); | |
| puts("Trying to get using a JSON decoded object property"); | |
| // This | |
| if (!this.objectHash[obj.id]) { | |
| puts("It wasn't set properly"); | |
| } | |
| else { | |
| puts("It was set properly"); | |
| } | |
| puts("Trying to get using a string object"); | |
| // This | |
| if (!this.objectHash[id]) { | |
| puts("It wasn't set properly"); | |
| } | |
| else { | |
| puts("It was set properly"); | |
| } | |
| } | |
| a = new Shazbot(); | |
| a.myFunction("22345678"); | |
| a.myFunction("abc45678"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment