Learning Objectives
➔ Whatis Typescript?
➔ What is a Variable?
➔ Data Types
➔ Arrays
➔ Enum
➔ Function
➔ Classes in Typescript
➔ Inheritance
➔ Getter & Setter
➔ Interfaces
➔ Decorators
3.
What is Typescript?
➔Typescript is a superset of JavaScript.
➔ TypeScript is strongly typed, whereas JavaScript is dynamically typed.
➔ TypeScript allows to specify the datatype explicitly.
➔ Typescript helps the user to write the JavaScript more easier with advanced
features.
➔ TypeScript cannot be directly executed by browsers like JavaScript.
➔ Instead TypeScript code is compiled to get JavaScript code.
What is aVariable?
➔ Named storage to store a value
➔ In typescript, the variables are strongly typed
6.
Datatypes
➔ String
◆ Usebackticks ` mystring ` - used to write an expression
◆ Even we can use variables ${var} using backticks (Template reference syntax)
➔ Number
➔ Boolean
Arrow Function
➔ Arrowfunctions have become the standard syntax in modern JavaScript.
➔ They offer a concise way to write functions, making your code lighter and
more readable
Getter & Setter
➔Getter will help the private
members to be accessed outside
the class.
➔ We use get keyword
➔ Setter will help us to set the
value of the private member
using set keyword.
18.
Interface
➔ An interfacein TypeScript
defines the expected
structure of an object.
➔ It provides a way to
describe the shape of
objects, including their
properties and methods,
without implementing any
functionality.
19.
Why Interface?
➔ ImprovedType Checking
➔ Easier to understand and
maintain the code.
➔ Interfaces can be extended and
reused across different parts of
the code.
Decorators
➔ It isa powerful feature in
Typescript which helps to
add functionality or modify
the behavior of classes,
methods, properties and
parameters at runtime.
➔ They are functions declared
using @ symbol.