Skip to content

Instantly share code, notes, and snippets.

@orlandov
Created June 4, 2010 21:55
Show Gist options
  • Select an option

  • Save orlandov/425992 to your computer and use it in GitHub Desktop.

Select an option

Save orlandov/425992 to your computer and use it in GitHub Desktop.
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