Category: 1. TypeScript

  • 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. Tuples can also be…

  • 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…

  • Boolean

    The TypeScript Boolean types represent logical values like true or false. Logical values are used to control the flow of the execution within the program. As JavaScript offers both Boolean primitive and object types, TypeScript adds a type annotation. We can create a boolean primitive as well boolean object. We can create a boolean object…

  • Strings

    In TypeScript, a string represents a sequence of characters. The string type is a fundamental data type in TypeScript. Strings are important to hold data that can be represented in text form. Like JavaScript, TypeScript also supports both string primitives and String objects. The String object lets you work with a series of characters. It wraps the…

  • 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. TypeScript number type represents the numeric values. All the numbers are represented as the floating point values. TypeScript…

  • Type Inference

    Type inference is a feature in TypeScript that allows the compiler to automatically determine (infer) the type of a variable, function or expression. TypeScript is an optionally static type programming language. You can declare variables, expressions, or functions without explicitly annotating their types. The compiler will automatically determine the types at the compile time. The…

  •  Type Annotations

    Type Annotations In TypeScript,type annotations offer a way to define (or annotate) the data types of variables, class members, function parameters and return values. TypeScript is a statically typed programming language that optionally supports the dynamic typing. Because of this support any JavaScript file (.js) can be directly renamed as a TypeScript file (.ts). As…

  • Types

    The Type System represents the different types of values supported by the language. The Type System checks the validity of the supplied values, before they are stored or manipulated by the program. This ensures that the code behaves as expected. The Type System further allows for richer code hinting and automated documentation too. TypeScript provides…

  • let & const

    TypeScript has the same rules as JavaScript to declare variables. Initially, only the ‘var’ keyword was used to declare the variable, but in the ES6 version of JavaScript ‘let’ and ‘const’ keywords are introduced to declare a variable. So, you can also use them in TypeScript. In this lesson, you will learn to declare a…

  • 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…