CodesJava

Easy learning with example program codes

typescript object tutorial


TypeScript Object:

A real world entity is known as an object. Like every real world object, software objects also have state and behavior. State of the object is represented by data members or fields and behavior is represented by methods.

In TypeScript an object represents an instance which contains set of key value pairs. The values can be scalar values, functions or array of other objects.

Syntax:

var objectName = { 
   key1: “value”, //scalar value 
   key2: function() {
      //functions 
   }, 
   Key3:[“content1”, “content2”] //collection  
};

Example:

class Employee { 
   //field 
   name:string; 
   empId:string;  
} 
//function
var display = function(obj: {name:string, empId:string}) { 
  console.log("Employee Name: "+obj.name);
  console.log("Employee EmpId: "+obj.empId);
} 
 
//create an object 
var obj:Employee = {name:"Jai", empId:"EMP024"};
 
//access the function
display(obj);

Try it:

JS Bin on jsbin.com

TypeScript Tutorial

TypeScript Overview.
Typescript vs Javascript.
Typescript let vs var.
TypeScript Hello World.
Typescript Data Types.
Typescript Variable Declaration.
TypeScript operators list.
TypeScript Arithmetic Operators.
TypeScript Comparison Operators.
TypeScript Bitwise Operators.
Typescript Logical Operators.
TypeScript Assignment Operators.
Typescript Conditional Operator.
Typescript String Operator.
Typescript typeof Operator.
TypeScript control statements.
TypeScript Switch Statement.
TypeScript for loop.
TypeScript for in loop.
TypeScript while loop.
TypeScript do while loop.
Typescript for loop break.
TypeScript for loop continue.
Typescript function.
Typescript returning function.
Typescript parameterized function.
Typescript function optional parameter.
Typescript rest parameters.
Typescript default parameters.
Typescript anonymous function.
Typescript function constructor.
Typescript Arrow/Lambda function.
Typescript function overloading.
TypeScript number object.
TypeScript string object.
TypeScript boolean object.
TypeScript date object.
TypeScript math object.
TypeScript array object.
TypeScript tuples.
TypeScript union type.
TypeScript interface.
TypeScript interface inheritance.
TypeScript interface multiple inheritance.
TypeScript class.
Typescript class inheritance.
Typescript class interface.
TypeScript abstract class.
TypeScript object.
TypeScript duck typing.
TypeScript NameSpace.
TypeScript Multi-file namespaces.
TypeScript module.
TypeScript ambient module.
Sign Up/ Sign In
Ask a Question


Industrial Training

We offers Placement Oriented Training on Java, Spring, JSF, Hibernate, PHP, AngularJS, Angular 4, PLSQL, Oracle BI Publisher etc. We also provides Online training, please mail us at hr@codesjava.com.

Development

We also provides the Development services for Website Development , Java Development, PHP Development, Android App Development etc. You can contact us on hr@codesjava.com.

Copyright © 2018 CodesJava DMCA.com Protection Status SiteMap Reference: Java Wiki