These are only present in TS not in JS.

This is a built in generic type. It says the names is an array of either strings or numbers.
Another generic type built in TS is the promise type. Promises are a JS feature. They can be created like:

Just note here if I hover over it, TS says it is of type Unknown because TS is not fully able to understand that it will actually resolve to a string here. So, we can do:

So, we get better type safety with generic types.
One good example is: https://www.youtube.com/watch?v=RHah57-vv-E(Must watch video)

Note: Here I am getting error because TS does not know wheather it has age or not. One solution can be to use type casting like:

But there is an easier way using generics:

Here, by extending object on line 14 we are saying that the passed parameter should be an object. This is called Type Constraints.
Note: extends = type constraints.
Another example:
