Skip to content

Instantly share code, notes, and snippets.

@joshuaebowling
Last active September 1, 2015 21:46
Show Gist options
  • Save joshuaebowling/103a6d33a74d982f5cc9 to your computer and use it in GitHub Desktop.
Save joshuaebowling/103a6d33a74d982f5cc9 to your computer and use it in GitHub Desktop.
/*======================================================================*\
ICBIaW50OiBtYWtlIHRoaXMgYXMgY2xvc2UgdG8gcHJvZHVjdGlvbi1yZWFkeSBzb3VyY2
UgY29kZSBhcyB5b3UgY2FuIQoKICBCb251cyBwb2ludHMgZm9yIHRlbGxpbmcgdXMgd2hh
dCB0aGlzIGRvZXMgaW4gcGxhaW4gdGVybXM6CgogICAgJycuam9pbihpdGVydG9vbHMuY2
hhaW4oKnppcChzWy0yOjotMl0sIHNbOjotMl0pKSk=
\*======================================================================*/
// I'm going to leave my debugging code in so you can see how I prove to myself that I've resolved issues
/* I added the NAMESPACE declaration to troubleshoot.
* I understand this was only part of a larger
* codeblock that may or may not have declared NAMESPACE
*/
var NAMESPACE;
if (NAMESPACE == null
|| typeof (NAMESPACE) == 'undefined') {
NAMESPACE = {};
var id = function (id) {
var _all_ids = new Array();
var persona = {};
// local var declaration
var _id = id;
/* because the id gets deleted from _all_ids on close() invocation, I imagine it should be added also.
* but I have no clue to what end numbers are added or deleted from this array.
*/
// added terminating semi-colon to end of function
var getId = function () {
return _id;
};
// assignment of function to returned object
persona.getId = getId;
// add the current _id to _all_ids
_all_ids.push(getId());
// local var declaration
var _closed = false;
// added terminating semi-colon to end of function
var close = function () {
delete _all_ids[getId()];
// the line below references a prototypal property that doesn't seem to be in existence
// this._closed = true;
// the output below should prove that this._closed is an improper reference
console.log('according to the original code, this should be false, not undefined.', this._closed);
// instead, I'll reference the local property created above
_closed = true;
};
persona.close = close;
return persona;
};
NAMESPACE['id'] = id;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment