Skip to content

Instantly share code, notes, and snippets.

@egermano
Created September 11, 2012 15:03
Show Gist options
  • Save egermano/3699476 to your computer and use it in GitHub Desktop.
Save egermano/3699476 to your computer and use it in GitHub Desktop.
Linked List
function LinkedList() {
this.head = null;
this.tail = null;
this.add = function(value) {
var node = new Node(value);
if (this.head == null) { this.head = node; }
if (this.tail != null) { this.tail.next = node; }
this.tail = node;
};
}
function Node(value) {
this.value = value;
this.next = null;
}
var list = new LinkedList();
list.add(1);
list.add(2);
list.add(3);
console.log(list);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment