Quiz · Generics · lesson 4 of 10
Quiz — T for two calls
Which types does TypeScript infer for a and b?
function last<T>(xs: T[]): T {
return xs[xs.length - 1];
}
const a = last([1, 2, 3]);
const b = last(["x", "y"]);
console.log(a, b);Which types does TypeScript infer for a and b?
function last<T>(xs: T[]): T {
return xs[xs.length - 1];
}
const a = last([1, 2, 3]);
const b = last(["x", "y"]);
console.log(a, b);