TypeScript Basics

TypeScript Record

TypeScript Record is a utility type that creates an object type where the keys and the values associated with those keys are of the specified types.

TypeScript Date

Learn to create new Date objects in TypeScript, and modify, compare and format them to custom and inbuilt locale-specific patterns.

TypeScript Tutorial

TypeScript is an open-source programming language that was developed and maintained by Microsoft in 2012. TypeScript brings ‘types’ (or datatypes) to JavaScript making a strongly typed language. This page lists down all the TypeScript tutorials posted on this blog for easy navigation. 1. TypeScript Basics 2. TypeScript Types 3. TypeScript …

TypeScript Callback Function Example

TypeScript supports callback functions to make your program asynchronous. A callback function is a function which is scheduled to be called after some asynchronous processing is completed.

TypeScript Function Overloading

In TypeScript, function overloading, or method overloading, is the ability to create multiple methods with the same name and a different number of parameters or types.

TypeScript Function Types

Learn to create functions in typescript and function type declaration. We will also see how to declare and pass optional parameters, setting default value for any parameter; and rest parameters with easy-to-follow examples. Table of Contents 1. Creating a function 2. Function Types 3. Optional Parameters 4. Parameters with Default …

TypeScript Template Strings

A typescript template string (or template literal) is a regular JavaScript string which is enclosed within the back-tick characters (`) seeded with multiple placeholders denoted with ${ }. At runtime, the code replaces the placeholders with their real values. The process of evaluating a template literal containing one or more …

TypeScript Set

Set is a new data structure introduced in ES6. It allows to store distinct values into a List. Learn to create set, add and iterate set values.

TypeScript Map

Map is a new data structure introduced in ES6, to store key-value pairs. Learn to create map, add, delete, retrieve and iterate over Map entries.

TypeScript For-loop, For..of and For..in

In TypeScript, You can iterate over iterable objects (including array, map, set, string, arguments object and so on) using for…of loop. To be an iterable, an object must implement the @@iterator method.

TypeScript Compiler Configuration

TypeScript compiler uses tsconfig.json to get configuration options for generating JavaScript code from TypeScript sourcecode. When you uses $ tsc command to compile TypeScript code, compiler searches for configurations loaded in tsconfig.json.

TypeScript Literal Types

In TypeScript, string literals allow you to specify the exact value a string must have in it’s lifespan. You can assume it a form as ‘string based enum’ which also is named group of string constants.

TypeScript Enum

In TypeScript, enums are set of named constants. Though it is optional, but enums should be a named group of related constants. TypeScript supports both traditional enums and string-based enums.

Difference between undefined and null

In JavaScript, a variable is said to be “undefined” if it has been declared but not initialized. Whereas “null” is assigned to a variable whose value is absent at the time of initialization. In simple words, when we do not assign any value to a variable, the JavaScript engine treats …

TypeScript Union Types

In TypeScript, a union type variable is a variable which can store multiple type of values (i.e. number, string etc). A union type allows us to define a variable with multiple types. The union type variables are defined using the pipe (‘|’) symbol between the types. The union types help …

Equals Operator ( == ) vs Strict Equals Operator ( === )

In TypeScript (or JavaScript), we can compare the two variables with either equality operator (‘==’) or strict equality operator (‘===’). Both comparison operators seems almost similar; but the way, they compare two given variables, is very different. The equality operator compares only the value after applying the type coercion, if …

TypeScript / JavaScript Spread Operator

The spread operator is a new addition to the features available in the JavaScript ES6 version. The spread operator is used to expand or spread an iterable or an array in Typescript or Javascript. 1. When to use the Spread Operator? The spread operator (in the form of ellipsis) can …

TypeScript Logical Operators

TypeScript logical operators are similar to what we have learned in JavaScript logical operators. These operators help in comparing boolean expressions and producing a single boolean value as result. 1. Logical Operators Operator Description Logical AND operator – && If both operands (or expressions) are true, then result will be …

TypeScript Comparison Operators

TypeScript comparison operators are the same as JavaScript. Comparison operators help in comparing two variables by their values. Please note that some operators use type coercion while comparing the values, while some do not. Please use them carefully. Type coercion means that when the operands of an operator are different …

TypeScript Type System

TypeScript supports type checking for all primitive types and object types. TypeScript also supports generics, decorators, and ES6 module types as well. It is important to learn that the type system in typescript is designed to be optional. So all programs written in JavaScript are TypeScript programs as well. Table …

Getting Started with TypeScript

In this TypeScript tutorial, learn to basics, compiler, installation and how to start development in TypeScript language with examples.

TypeScript Arithmetic Operators

An operator is a symbol that represents a specific action. An arithmetic operator can be used with one or more than values to produce a single value. In typescript, we can perform arithmetic operations using below given 10 operators. Arithmetic operators Operator Name Description and Example x + y Addition …

Difference between let, var and const

In vanilla JavaScript, variables are declared using ‘var‘ keyword. In version ES6, we can define the variables using let and const keywords too. All three keywords have similar syntax for variable declaration and initialization, but they differ in their scope and usage. 1. Differences between var, let and const We …

JavaScript Variable Hoisting

Variable hoisting in JavaScript means to move all variable declarations to top of function. This means that if we declare a variable at the end of a function, the runtime will hoist it to the top and we will not have any error if we would have used that variable …

Truthy and Falsy Expressions

In JavaScript, Truthy expressions evaluate to boolean true value and Falsy expressions evaluate to boolean false value. Unlike other programming languages, truthy and falsy values are not limited to boolean data types and comparisons. They can have many other forms. Let us learn what makes an expression truthy or falsy …

Transpiler vs Compiler

Transpilers, or source-to-source compilers, are tools that read the sourcecode written in one programming language and produce the equivalent code in another programming language with a similar level of abstraction. A good example of transpiler is the Typescript transpiler which converts Typescript code to JavaScript. Similarily, Babel transpiler can also …

About Us

HowToDoInJava provides tutorials and how-to guides on Java and related technologies.

It also shares the best practices, algorithms & solutions and frequently asked interview questions.