TypeScript

Ternary Conditional Operator Typescript

The Typescript conditional operator is a Ternary Operator, which takes three operands. The first operand is a condition to evaluate. It is followed by a question mark (?), then an expression (expression1). It is then followed by a colon (:) and second expression (expression2). If the condition is true, then expression1 executes & if the condition is false, then expression2 executes. The conditional operator is a shorthand way to write an If statement.

Typescript Enum All you need to know

A Typescript enum allows us to define the collection of related values to be used by name. They make the code easier to read. You may use them when you want to limit the values that a variable can take to a small set of possible values. Javascript does not support enums, hence typescript creates runtime artifact to support them ( Except, const enum which do not have a runtime artifact). TypeScript provides both numeric and string-based enums.

Type Assertion in TypeScript

Type Assertion allows us to override the compiler determined type in our code. It is something similar to type casting in other languages. except that it does not restructure or modify the type in any way. The Type Assertion in TypeScript is a compile-time feature

Scroll to Top