TypeScript_Basic 4:What is function| Type of functions in TypeScript |Arrow and Overloading function

Опубликовано: 04 Октябрь 2024
на канале: Codenbox AutomationLab
770
10

#TypeScript #function #cypress
+What is function?
+Type of functions in TypeScript?
+Lambda functions in TypeScript?
+Arrow function and Overloading functions in TypeScript?

▬▬▬▬▬▬ In this Video ▶️ ▬▬▬▬▬▬
A function is a block of code designed to perform a particular task.
Reuse code: Define the code once and use it many times.
A function is executed when "something" invokes it (calls it).
Function Syntax:
function name(parameter1, parameter2, parameter3)
{ // code to be executed }
-Function parameters are listed inside the parentheses () in the function definition.
-Function arguments are the values received by the function when it is invoked.
How function get invoke:
-When an event occurs (when a user clicks a button)
-When it is invoked (called) by the function name
-Automatically (self invoked).

Type of functions in TS:
-Named: A named function is one when you declare and call a function by its given name.
-Anonymous: An anonymous function is one which is defined as an expression. This expression is stored in a variable. So the function itself does not have a name. This function is invoked using variable name that the function is stored in.

Arrow functions: When we use Fat arrow notations for anonymous functions (i.e for function expressions) is called Arrow function. It is also known as lambda functions in other languages.

Function Overloading: TypeScript provides the concept of function overloading. You can have multiple functions with the same name but different parameter types and return type. However, the number of parameters should be the same.


▬▬▬▬▬▬ Useful Links 🛠 ▬▬▬▬▬▬
Blog ► http://codenboxautomationlab.com/​​​
GitHub Repo ► https://github.com/codenbox​​
TypeScript Site ► https://www.typescriptlang.org/


▬▬▬▬▬▬ Connect with us 👋 ▬▬▬▬▬▬
~~~Subscribe to this channel, and press bell icon to get all updated videos on Selenium and Cypress Automation:
   / codenboxaut.  .

~~~ Follow us on Facebook & Twitter to get more updates:
  / ​​​