对象作为函数形参
var obj={x:1,y:"你"
}
interface objType{x:number,y:string
}
var fun=(obj1:objType)=>{console.log(obj1.x,obj1.y);
}
fun(obj);
对象作为返回值
var a={x:1,y:"你"
}
var b={x:2,y:"好"
}
interface objType{x:number,y:string
}
var fun=(obj1:objType,obj2:objType):objType=>{return {x:obj1.x+obj2.x,y:obj1.y+obj2.y}
}
console.log(fun(a,b))