By 06/07/2015 5 Comments

TypeScript Default Parameter List

Default Parameter List:

  • TypeScript defines the default parameters in the function which allows us to specify default values of parameters.
  • If we do not pass an argument explicitly to a function parameter that the TypeScript sets the default value to a parameter and do not returns “undefined” value.
  • TypeScript makes the parameter optional automatically by using the default parameter syntax.

Example:

/* A string type anonymous function declaration which has 4 parameters. Notice that last two parameters (php and html) are marked as default. */
var pLanguages = function (asp: string, js: string, php: string = "Php", html: string = "Html"): string {
    return (asp + " , " + js + " , " + php + " , " + html);
};

/* Call and print the above anonymous function, 2 parameters are passed from it. Other 2 are optional parameters which are used as default. */
document.write(pLanguages("Asp.net", "JavaScript"));

 






Next Tutorial →


← Previous Tutorial


Leave your valuable Comment

Have a natural attraction for women cosmetics and replica watches uk clothes, no
more than two for men the most attractive one, is to make their own driving experience, happy and can serve as the facade of the car, another is to highlight the taste edify sentiment rolex replica watch. The replica rolex is undoubtedly the most fashionable accessories, wear a suit to attend the activities, but also get a decent match on the replica watches .