Typescript object example |typescript Example program

What is Object:-

  • Object is the primary concept in OOP (Object Oriented Programming).
  • “Object” represents a physical item, that represents a person or a thing.
  • Object is a collection of properties (details) and methods (manipulations).
  • For example, a student is an “object”.
  • We can create any no. of objects inside the program.

Creating Object:-

  • Object can be created by using “Object Literal Pattern” in TypeScript.
  • “Object literal” is a collection of properties and methods, that are enclosed within curly braces { }.
  • Syntax to create Object:

Reference Variable:-

  • The “reference variable” is a variable, that can store the reference of an object.
  • We can access all the properties and methods of the object, by using the “reference variable”.
  • Syntax to create Object and store its reference in the “reference variable”: