class NumberNode {
public data: number;
public next: NumberNode;
public constructor(data: number) {
this.data = data;
}
}
class SLList {
private head: NumberNode;
public push(data: number) {
const node = new NumberNode(data);
node.next = this.head;
this.head = node;
}
}
const list = new SLList();
list.push(3);
list.push(2);
list.push(1);
console.log(list);
To embed this project on your website, copy the following code and paste it into your website's HTML: