Created
August 8, 2013 03:07
-
-
Save PuercoPop/6181106 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
; | |
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