单项选择题

下列代码的输出结果是(   )。
function attr(name: string): string;
function attr(age: number): string;
function attr(nameorage: any): any {
    if (nameorage && typeof nameorage === "string") {  //代表当前是名字
        console.log("ming")
    } else {
        console.log("age");
    }
}
attr("hello");   
A、运行错误
B、运行正确,结果为h
C、运行正确,结果为he
D、运行正确,结果为hello

微信扫码免费搜题