TypeScript tuple

TypeScript tuples: Typescript tuple represents a heterogeneous collection of values i.e. it contains a collection of values of different types. Syntax: var tupleName = [value1,value2,value3,…valuen] Example: function tupleTest(values):void{ for (i=0;i

TypeScript array

TypeScript array object: A TypeScript Array object represents a collection of elements of the same type. TypeScript Array Object Properties: Property Description constructor Returns a reference to the array function that created the object. length It reflects the number of elements in an array. prototype It allows us to add properties and methods to an … Read more

TypeScript math

TypeScript math object: A TypeScript Math object provides no. of properties and methods for performing mathematical operations. Math is not a constructor and all the properties and methods of Math are static. TypeScript Math Object Properties: Property Description E \ Euler’s constant and the base of natural logarithms, approximately 2.718. LN2 Natural logarithm of 2, … Read more

TypeScript date

TypeScript date object: A TypeScript Date object represents a date. We can get or set year, month and day, hour, minute, second, and millisecond fields of the object by Date methods. TypeScript Date Object Properties: Property Description constructor It specifies the function that creates an object’s prototype. prototype It allows us to add properties and … Read more

TypeScript boolean

TypeScript boolean object: A TypeScript Boolean object can represents two values “true” or “false”. How to create TypeScript boolean object: By using boolean literals. By using Boolean() constructor. Syntax: Var b1:boolean = true; var b2:boolean = new Boolean(value); Example: function booleanTest(bVar:boolean):void{ console.log(bVar.valueOf()); } var boolean1:boolean=new Boolean(true); var boolean2:boolean=new Boolean(false); var boolean3:boolean=true; booleanTest(boolean1); booleanTest(boolean2); booleanTest(boolean3);

TypeScript string object

TypeScript string object: A TypeScript String object represents a sequence of characters. TypeScript String Object Properties: Property Description constructor It returns a reference to the String function that created the object. length It returns the length of the string. prototype It allows us to add properties and methods to an object. TypeScript String Object Methods: … Read more

TypeScript number object

TypeScript number object: The TypeScript Number object represents numerical data which can be integers or floating-point numbers. TypeScript number constants/properties: Property Description MAX_VALUE It specify the largest possible value. MIN_VALUE It specify the smallest possible value. NaN Equal to a value that is not a number. NEGATIVE_INFINITY A value that is less than MIN_VALUE. POSITIVE_INFINITY … Read more

TypeScript Function

A TypeScript function is a group of statements which is used for performing a specific task. It provides the facility of code re-usability. Typescript function declaration: function function_name() { // function body } Typescript function invocation: function_name(); Typescript Function Example: function hello() { //function definition console.log(“Hello World!”); } hello();//function invocation Typescript returning function Typescript returning … Read more

TypeScript do while loop

The do while loop repeatedly executes a block of statements until a particular condition is true. It first executes a block of statements and then check the condition. Syntax: do { //Block of statements }while(condition); TypeScript do while loop example: var num:number=1; do{ console.log(num); num++; } while (num

TypeScript while loop

The while loop repeatedly executes a block of statements until a particular condition is true. It first check the condition and executes a block of statements if condition is true. Syntax: while(condition){ //Block of statements } TypeScript while loop example: var num:number=1; while (num