Quick actions

cmd+k|ctrl+k

Navigation

Languages

Linked List Implementation

Snippet info

Language

JavaScript

Visibility

public

Author

bhattabhi1289

Created

2023-03-02T15:38:01.245391Z

Updated

2023-03-16T15:28:42.264665Z


class LinkedList{
    constructor(value){
        this.head= {
            value:value,
            next:null
        };
        this.tail=this.head;
        this.length=1;
        
    }
    append(value){
        const newNode={
            value:value,
            next:null
        }
        // this.head.next={
        //     value:value,
        //     next:null
        // };
        console.log('thisss',this.head);
         console.log('thisss',this.tail)
        this.tail.next=newNode; 
        this.tail=newNode;
        ++this.length;
        
    }
}
const myList= new LinkedList(10)
myList.append(5)
//myList.append(16)
console.log(myList)
INFO