面试题答案
一键面试function extractStrings<T>(arr: T[]): string[] {
let result: string[] = [];
for (let item of arr) {
if (typeof item ==='string') {
result.push(item);
} else {
console.error(`Element of type ${typeof item} is not a string.`);
}
}
return result;
}