What is the difference between generic Type(T) vs any in typescript?
Function 1
function identity(arg: any): any {
return arg;
}
Function 2
function identity<T>(arg: T): T {
return arg;
}
Function 3
function identity<T>(arg: T[]): T[] {
return arg;
}
Function 1 & 3 is accepted if we passing any kind of
data type, But the function 2 does not accept if we pass anarray. generic type is accepting all kind of data type on compile time. but here why it does not accept?
Also which function is good for better performance ( function 1 or function 3)?