TypeScript | TypeScript Functions | Question10

Last Updated :
Discuss
Comments

Consider the following code in TypeScript. What is the result when the function sum() is called with two string arguments?

JavaScript
function sum(a: number, b: number): number;
function sum(a: string, b: string): string;
function sum(a: any, b: any): any {
    return a + b;
}
console.log(sum("Hello", "World"));


HelloWorld

NaN

"Hello World"

undefined

Share your thoughts in the comments