TypeScript for in loop

The for in loop is used to iterate the properties of an object. Syntax: for(property in object){ //Block of statements } TypeScript for in loop example: var person = {Fname:”Rajeev”, Lname:”Johari”, Age:40}; var perproperty; for (perproperty in person) { console.log(perproperty + “: ” + person[perproperty ]); }  

TypeScript for loop

The for loop repeatedly executes a block of statements until a particular condition is true. Syntax: for(initialization; condition; statement){ //Block of statements } Where: initialization statement: is used to initialize the loop variable. boolean expression: is used for condition check whether returns true or false. statement: is used for either increment or decrements the loop … Read more

TypeScript switch statement

TypeScript switch statement is used to execute a block of statement based on the switch expression value. It is like if else if statement. Syntax: switch(expression){ case value1: //TypeScript block of statements break; case value2: //TypeScript block of statements break; … default: //TypeScript block of statements break; } TypeScript Switch Statement Example: var today:string; switch … Read more

TypeScript control statements

TypeScript control statement is used to control the flow of program based on the specified condition. TypeScript control statements: 1. If Statement 2. If else statement 3. if else if statement TypeScript If Statement: If statement is used to execute a block of statements if specified condition is true. Syntax: if(condition){ //Block of TypeScript statements. … Read more

TypeScript operators list

Commonly used TypeScript operators list: Arithmetic Operators Comparison Operators Bitwise Operators Logical Operators Assignment Operators Conditional Operator String Operator typeof Operator   TypeScript Arithmetic Operators: Arithmetic operators are used to perform arithmetic operations. TypeScript Arithmetic Operators List: Operator Description Example + Addition 30+20 = 50 – Subtraction 30-10 = 20 * Multiplication 10*10 = 100 … Read more

Variables in typescript

Variable is the name of reserved memory location. It means when we declare a variable some part of memory is reserved. Rules for declaring a TypeScript variable: TypeScript variable name must begin with a letter, underscore, or dollar sign. TypeScript variable names are case sensitive. TypeScript reserved keywords like abstract, boolean etc can’t be used … Read more

TypeScript Data Types system

When a variable is declared some part of memory is reserved. But how much memory will be reserved. It depends upon the data type of the variable.  i.e. how much memory will be reserved and which type of data can be stored in reserved memory is depends upon data type of the variable. The Type … Read more

Typescript hello world

Let us start TypeScript programming with simple “Hello World!” example. Create and save the file with .ts extension. In first line we declare a variable of string type. In second line we display the variable’s value at the terminal window. TypeScript Hello World: var message:string = “Hello World!” ; console.log(message); As we discussed in earlier … Read more

Difference between var and let

var keyword: The var statement is used to declare a variable. We can optionally initialize the value of that variable. Example: var num =10; let keyword: The let statement is used to declare a local variable in a block scope. It is similar to var, in that we can optionally initialize the variable. Example: let … Read more

Differences Between JavaScript And TypeScript

JavaScript: JavaScript is the most popular programming language. It is lightweight and commonly used to create interactive and dynamic web pages. It is developed by Netscape in 1995 and named as LiveScript which is later renamed to JavaScript. Read more on JavaScript. TypeScript: TypeScript: TypeScript is a superset of JavaScript which primarily provides optional static … Read more