Generics
type ListNode = {
value: any;
next: ListNode|null;
}
function add(head: ListNode, value: any): ListNode {
const newElement: ListNode = { value, next: null };
let current: ListNode = head;
while (current.next) {
current = current.next;
}
current.next = newElement;
return current;
}A generic type
Generic functions
Resources
Last updated