Types of Linked List | Structure of Node ; Function to print the content of linked list starting from the given node ; Iterate till n reaches null ; Print the data ; Driver Code ; Allocate 3 nodes in the heap ; Assign data in first node ; Link first node with second ; Assign data to second node ; Assign data to third node
class Node { constructor ( ) { this . data = 0 ; this . next = null ; } } function printList ( n ) { while ( n != null ) { document . write ( n . data + " " ) ; n = n . next ; } } let head = null ; let second = null ; let third = null ; head = new Node ( ) ; second = new Node ( ) ; third = new Node ( ) ; head . data = 1 ; head . next = second ; second . data = 2 ; second . next = third ; third . data = 3 ; third . next = null ; printList ( head ) ;