0% found this document useful (0 votes)
0 views

Typescript Functions

The document provides an overview of TypeScript functions, explaining their syntax, parameters, and arguments. It distinguishes between different types of functions, including named, anonymous, and arrow functions, highlighting their characteristics. Additionally, it emphasizes the benefits of using functions for code reuse and flexibility in handling different inputs.

Uploaded by

11ahmedansari
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

Typescript Functions

The document provides an overview of TypeScript functions, explaining their syntax, parameters, and arguments. It distinguishes between different types of functions, including named, anonymous, and arrow functions, highlighting their characteristics. Additionally, it emphasizes the benefits of using functions for code reuse and flexibility in handling different inputs.

Uploaded by

11ahmedansari
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Exams Preperation

SESSION 04
TypeScript

FUNCTIONS
A TypeScript function is a
block of code designed to
perform a particular task.
Functions
A TypeScript function is
executed when "something"
invokes it (calls it).
Example
TypeScript
Function Syntax
A TypeScript function is defined with the function keyword,
followed by a name, followed by parentheses ().

The parentheses may include parameter names separated by


commas: (parameter1, parameter2, ...)

The code to be executed, by the function, is placed inside curly


brackets: { }
Example
Function
Paramters & Arguments
Function parameters are listed inside the parentheses ()
in the function definition.

Function arguments are the values received by the


function when it is invoked.

Inside the function, the arguments (the parameters) behave


as local variables.
{
Parameters

Arguments

{
Types Of
FUNCTIONS
Anonymous
Function

Name Arrow
Function Function
Examples

Named Function Anonymous Function Arrow Function


Traditional way Without name One-lined function
This type receives a name for the This type doesn't receive any name for Arrow functions are been introduced in
function declaration. declaration. Instead, the function will be the ES6 version. It is used to shorten the
assigned to a variable for invoking. code.
Why
Functions
With functions you can reuse code.

You can write code that can be used many


times.

You can use the same code with different


arguments, to produce different results.
@CodeWithHamza

LinkedIn/HamzaMirza

Instagram/codewithhamzaofficial

[email protected]

You might also like