implementation of linked lists in JavaScript