function attr(name:string):string; function attr(age:number):string; function attr(nameorage:any):any{ if(nameorage &&typeof nameorage ==="string"){//代表当前是名字 alert("ming") }else{ alert("age"); } } attr("hell"); attr(10);
function attr(name:string):string; function attr(age:number):string; function attr(nameorage:any):any{ if(nameorage &&typeof nameorage ==="string"){//代表当前是名字 alert("ming") }else{ alert("age"); } } attr("hell"); attr(10);