Skip to content

Instantly share code, notes, and snippets.

@PuercoPop
Created August 8, 2013 03:07
Show Gist options
  • Save PuercoPop/6181106 to your computer and use it in GitHub Desktop.
Save PuercoPop/6181106 to your computer and use it in GitHub Desktop.
;
var Node = function(value) {
this._datum = value;
};
Node.prototype = {
get datum() {
return this._datum
},
set datum(v) {
this._datum = v;
},
get next() {
return this._next;
},
set next(v) {
this._next = v;
},
append: function(node) {
if (this.next == undefined) {
this.next = node;
} else {
this.next.append(node);
}
},
log: function() {
if (this.next == undefined) {
console.log(this.datum)
} else {
console.log(this.datum);
this.next.log()
}
}
};
var ll = new Node(3);
ll.append(new Node(5));
ll.append(new Node(11));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment