Posts

Showing posts from October, 2020

Day 9 : TypeScript

Image
  Constructor : Constructor is a special type of  method or function which is called at the time of object creation. The constructor method is always defined with "constructor" keyword. The class always having a constructor is not needed or necessary. The members of the class in a constructor are accessed using "this" keyword. Syntax : constructor () { //statements                                                               } Example :      Access Modifiers : The access modifiers are used for controlling the visibility or availability of its data members. Mainly their are three types of access modifiers : 1) Public : By default, all members or functions of class are public. Public members are accessible anywhere in the program. 2) Private : The private members are accessible only within the class and its chi...

Day 8 : TypeScript

Image
Basic Concepts in TypeScript: Variable declaration : The default or traditional declaration of variable is : var a : number = 10; The let and const are two new concepts in variable declaration. The let keyword is some what same as var keyword. The let keyword allows user to avoid some of "gotchas" that we use in JS. Now, you all wondering what is "gotchas"??                 Gotchas are nothing but some what errors which we can avoid for better output. Consider a loop as an example : //var keyword gives access to i outside loop. //code:                 for(var i=0;i<5;i++) {                    console.log(i);               }               console.log(i); //output: 0 1 2 3 4 5 //let keyword not gives access to i outside loop. //code :         ...

Day 7 : TypeScript

Image
  TypeScript : Basic Introduction : TypeScript is an open-source, object-oriented programming language. TypeScript is developed and maintained by “Microsoft” and introduced by “Anders Hejlsberg” . TypeScript is a strongly typed superset of JavaScript. TypeScript is the ES6 version of JavaScript with some additional features. TypeScript cannot be directly run on the browser. TypeScript is a language as well as a set of tools. Features : TypeScript extends JavaScript and makes it strongly typed.                        - Strongly typed means when we write the code the datatype is checked. During the development phase errors and issues are caught. All JavaScript code are valid TypeScript code. TypeScript gives us benefit of OOP features, classes, closures and IIFE.  Why we use TypeScript instead of JavaScript?? Firstly JavaScript language is introduced for client-side. After that the Node.js makes JavaScript server-side t...