Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


Making the Linked List varied from the Linked List in C because JavaScript does not have structures, it has functions that act like STRUCTURESC structs


Unlike classes in Python or Java, there is not a need to write get and set function to modify these fields.  Instead, they can be reaches using object.field. These show polymorphism in JavaScript because the node can be used to save any type of item.  


The benefit of this implementation is that some functions can be used more than once rather than writing a new function or needing to use generic types to implement the functions with different types.  A drawback of this implementation is that it is more difficult to know which functions can be used with each type - for example, the == can not be used to compare strings in some languages, so since it is not explicit it could be hard to know whether it can be used on strings in Javascript. 


  1.  The first extension I completed was to create a delete function.  It takes in an index and it loops over the linked list until it gets to the index-th node.  Then it removes that node from the LinkedList by moving pointers of nodes around it and returns the item in that node.  Although I did this in other languages, this was particularly difficult because I had problems with the get and set functions of JavaScript.  Since I am using Javascript embedded in HTML and run the program in Google Chrome, I get no error messages when I have accessed a field incorrectly.  Thus, I took me a long time to troubleshoot.  Here is the delete related output:
    Image Added
  2. Due to my troubles in the last extension, I decided to investigate other ways to run JavaScript program.  I found the program NodeJS, which allows you to run JavaScript programs from the command line.  After downloading it and experimenting with using the terminal interface for node, I tried to transfer the program I had written for the main part of the project so I could use it with NodeJS.  I found I had to make small syntax changes, mostly related to how I print, but I was amazing because it threw me errors any time I made a mistake.  I plan to use NodeJS in the future. 
    Image AddedImage AddedImage Added