Master TypeScript From Scratch

Learn TypeScript step by step with practical examples, interactive coding lessons, and real-world projects.

TypeScript Practical Examples

Learn TypeScript through practical coding examples, DOM manipulation, form validation, real-world problems, mini projects, and interview preparation.

TS

Learn by Doing

Understand the concept, write the code, test the output, and build your confidence.

Welcome to TypeScript Examples

This section of the CIIT Training Institute tutorial helps learners apply TypeScript concepts to practical programming tasks. Each topic focuses on the purpose of the concept, how the code works, and the expected result.

💻
Practical Coding

Practice functions, arrays, objects, types, and reusable code.

🌐
Web Development

Interact with HTML elements and respond to browser events.

🚀
Mini Projects

Combine TypeScript concepts to build small applications.

🎯
Interview Preparation

Revise concepts and practice technical questions.

Explore TypeScript Topics

Select a topic below to start learning.

5 Learning Topics
🌐

DOM Manipulation

Learn how TypeScript interacts with HTML elements and updates the content and behaviour of a webpage.

  • DOM introduction
  • Selecting HTML elements
  • Changing text and styles
  • Handling browser events
Explore DOM Manipulation →
📝

Form Validation

Understand how to validate user inputs and display helpful messages before processing form data.

  • Required field validation
  • Email validation
  • Password validation
  • Displaying validation messages
Explore Form Validation →
⌨️

Practical Examples

Improve programming skills through practical problems using TypeScript features.

  • String and number operations
  • Arrays and objects
  • Functions and interfaces
  • Real-world programming problems
Explore Practical Examples →
🚀

Mini Projects

Apply your knowledge by building small applications that combine multiple TypeScript concepts.

  • To-Do List
  • Student Management
  • Simple Calculator
  • Expense Tracker
Explore Mini Projects →
🎯

Interview Questions

Revise TypeScript concepts and prepare for technical interviews with topic-wise questions.

  • TypeScript fundamentals
  • Types and interfaces
  • Functions and OOP
  • Advanced TypeScript concepts
Explore Interview Questions →
🧠

Coding Practice

Strengthen your understanding by solving problems, testing different inputs, and explaining your solutions.

  • Write code independently
  • Test different inputs
  • Identify and fix errors
  • Improve problem-solving skills
Start Coding Practice →

Recommended Learning Roadmap

Follow this sequence to move from individual examples to complete mini projects.

1
DOM Manipulation

Start by selecting elements, changing content, and handling click events.

Start this topic →
2
Form Validation

Practise input validation and build helpful form feedback.

Start this topic →
3
Practical Examples

Apply functions, arrays, objects, and interfaces to coding problems.

Start this topic →
4
Mini Projects

Combine different concepts to create useful applications.

Start this topic →
5
Interview Questions

Review important topics and prepare to explain your code.

Start this topic →

TypeScript Practical Example

Example: Calculate a student's total marks using an interface, an array, and a function.

interface Student {
    name: string;
    marks: number[];
}

function calculateTotal(student: Student): number {
    return student.marks.reduce(
        (total, mark) => total + mark,
        0
    );
}

const student: Student = {
    name: "Rahul",
    marks: [80, 75, 90]
};

console.log("Student: " + student.name);
console.log("Total Marks: " + calculateTotal(student));

Expected Output

Student: Rahul
Total Marks: 245
Concepts used: Interface, number array, function parameter typing, return type, and the reduce() array method.

Tips for Effective Learning

1. Write Code Yourself

Type the examples rather than only copying them. Change the values and observe the results.

2. Understand the Output

Trace the execution step by step and understand why the result appears.

3. Practise Error Handling

Test valid, invalid, and unexpected inputs to understand how your code responds.

4. Build Small Projects

Combine multiple concepts into small applications to strengthen your practical skills.

Summary

  • Learn TypeScript through practical coding examples.
  • Use DOM manipulation to interact with webpage elements.
  • Use form validation to check user inputs.
  • Practise programming problems to strengthen problem-solving skills.
  • Build mini projects to combine different TypeScript concepts.
  • Prepare for interviews by revising important technical questions.