TypeScript Tutorials - 05 TypeScript Variable Declaration

Published: 03 August 2017
on channel: Ashman Malhotra
345
4

“Typescript Variable Declaration”

We can declare variables in TypeScript the same we used to declare a variable in JavaScript. We can make use of var keyword to declare variables.

In this lesson, I will discuss problems associated with variable declaration method of JavaScript using var keyword. I will help you understand my point with a very simple example.

So, let’s create a TypeScript file.

The problem with this method is that we can access variable i outside the scope of for block. If you will recall the strict Object Oriented Language that you may have studied in past, variables are inaccessible outside their scope block.

In the current scenario, the scope of the variable i is within the for loop. Therefore, it should not be accessible outside the for loop block.

How can we resolve this problem?
The solution is let keyword. With let keyword, we can implement Block-Scoping. I will make changes in the code to help you understand what I mean.

In our current code, I am going to replace var keyword with let keyword.

   • TypeScript Tutorials - 05 TypeScript Varia...  
*********************************************************************
Please subscribe to my channel:
https://www.youtube.com/c/ashmanmalho...
*********************************************************************
Thank you for watching my video on "TypeScript Introduction"
*********************************************************************
Contact: training@ashman.in for training inquiries
*********************************************************************
"TypeScript Programming Basics" | "TypeScript variableIntroduction" | "Strongly Types TypeScript” | “Typed Script”


On this page of the site you can watch the video online TypeScript Tutorials - 05 TypeScript Variable Declaration with a duration of hours minute second in good quality, which was uploaded by the user Ashman Malhotra 03 August 2017, share the link with friends and acquaintances, this video has already been watched 345 times on youtube and it was liked by 4 viewers. Enjoy your viewing!