class Box<T> generic
choose the type parameter T
new Box<number>()
value to push
contrast: drop type safety
Use raw Box<any>
A raw box accepts anything — no compile check. The bug surfaces later, at runtime.
The box 1 item ← typed: errors caught early
Box<number>
console
A typed box rejects the wrong type before it runs. The raw box accepts anything, then crashes at runtime. Generics move the error earlier.