Author: admin
-
Union
TypeScript 1.4 gives programs the ability to combine one or two types. Union types are a powerful way to express a value that can be one of the several types. Two or more data types are combined using the pipe symbol (|) to denote a Union Type. In other words, a union type is written…
-
Tuples
At times, there might be a need to store a collection of values of varied types. Arrays will not serve this purpose. TypeScript gives us a data type called tuple that helps to achieve such a purpose. It represents a heterogeneous collection of values. In other words, tuples enable storing multiple fields of different types.…
-
Arrays
The use of variables to store values poses the following limitations − TypeScript introduces the concept of arrays to tackle the same. An array is a homogenous collection of values. To simplify, an array is a collection of values of the same data type. It is a user defined type. Features of an Array Here…
-
Strings
The String object lets you work with a series of characters. It wraps the string primitive data type with a number of helper methods. Syntax var var_name = new String(string); A list of the methods available in String object along with their description is given below − S.No. Property & Description 1. ConstructorReturns a reference…
-
Numbers
TypeScript like JavaScript supports numeric values as Number objects. A number object converts numeric literal to an instance of the number class. The Number class acts as a wrapper and enables manipulation of numeric literals as they were objects. Syntax In case a non-numeric argument is passed as an argument to the Number’s constructor, it…
-
Functions
Functions are the building blocks of readable, maintainable, and reusable code. A function is a set of statements to perform a specific task. Functions organize the program into logical blocks of code. Once defined, functions may be called to access code. This makes the code reusable. Moreover, functions make it easy to read and maintain…
-
Loops
You may encounter situations, when a block of code needs to be executed several number of times. In general, statements are executed sequentially: The first statement in a function is executed first, followed by the second, and so on. Programming languages provide various control structures that allow for more complicated execution paths. A loop statement…
-
Decision Making
Decision-making structures require that the programmer specifies one or more conditions to be evaluated or tested by the program, along with a statement or statements to be executed if the condition is determined to be true, and optionally, other statements to be executed if the condition is determined to be false. Shown below is the…
-
Operators
What is an Operator? An operator defines some function that will be performed on the data. The data on which operators work are called operands. Consider the following expression − 7 + 5 = 12 Here, the values 7, 5, and 12 are operands, while + and = are operators. The major operators in TypeScript can be…
-
Variables
A variable, by definition, is “a named space in the memory” that stores values. In other words, it acts as a container for values in a program. TypeScript variables must follow the JavaScript naming rules − A variable must be declared before it is used. Use the var keyword to declare variables. Variable Declaration in TypeScript The…