#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

#7 Type Alias (Advanced Types)

#11 Nullable Type (Advanced Types)

#4 Built in Types in TS (Fundamentals of TS)