#5 Functions (Fundamentals of TS)

 While writing a function in a TypeScript, give type for the function as well as the prop.

Example:

function User(age: number, id: number ):number {
    if(age>20){ 
        return id+2;}
    else{
        return id-2}

User(2,5);

Comments

Popular posts from this blog

#6 Objects (Fundamentals of TS)

#8 Union Type (Advanced Types)