Advertisement
Guest User

Untitled

a guest
Feb 19th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. class Node {
  2. constructor(item) {
  3. this.item = item;
  4. this.next = null;
  5. }
  6. }
  7.  
  8. class MyList {
  9. constructor(item) {
  10. this.head = new Node(item);
  11. this.length = 0;
  12. }
  13.  
  14. addFirst(item) {
  15. var node = new Node(item)
  16. node.next = this.head
  17. this.head = node;
  18. this.length++;
  19. }
  20.  
  21. get(index) {
  22. var node;
  23. return node;
  24. }
  25.  
  26. remove(index) {
  27. var node;
  28. }
  29. }
  30.  
  31. var list = new MyList(0);
  32. list.addFirst(1);
  33. list.addFirst(2);
  34. console.log(list.head);
  35. console.log(list.head.next);
  36. console.log(list.head.next.next);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement