Javascript implementation of a singularly linked list data structure