Data Types in Hindi

Typescript – User-Defined Data Type In Hindi

TypeScript

Typescript User-Defined Data Type In Hindi – Is Post Ts User Defined Data Types Ko Dekhne Wale Hai And Inke Example Bhi Dekhne Wale Hai |

Yadi Aapne  HTML Full Course  And CSS Full Course And Python Full Course And PHP Full Course Nhi Read Kiya Hai To Aap Vah Bhi Read Kar Sakte Hai |

Typescript User-Defined Data Type In Hindi

Typescript Inn User-Defined Data Types Ko Support Karta Hai.

TypeScript Type

Array

Array Same Data Type Ke Elements Ka Collection Hai.Javascript Ki Tarah, Typescript Me Bhi Hum Array Ki Values Ke Sath Kaam Kar Sakte Hai.

Array Ko Define And Initialize Karne Kaa Tareeka-

var list : number[] = [1, 3, 5];

Generic Array Type-

  1. var list : Array<number> = [1, 3, 5]; 

Tuple

Tuple Ek Aisa Data Type Hai Jo Different Data Type Ke Two Sets Of Value Ko Include Karta Hai.Yadi Aap Value Ko Number And String Ke Pair Me Represent Karna Chahte Hai To Iss Tarah Kar Sakte Hai-

Also Read – What Is TypeScript 

Example:

// Declare a tuple  
let a: [string, number];  
 
// Initialize it  
a = ["hi", 8, "how", 5]; // OK  

Interface

Interface Ek Aisa Structure Jo Application Me Contract Ki Tarah Act Karta Hai.Vah Class Ko Interface Ko Implement Karti Hai Vo Iske Saare Members Ko Implement Karne Ke Liye Bound Ho Jaati Hai.Isko Instantiated  To Nahi Kiya Jaa Sakta But Jo Class Isko Implement Karti Hai Vo Isko Referenced Kar Sakti Hai.

Example:

interface Calc {  
    subtract (first: number, second: number): any;  
}  
   
let Calculator: Calc = {  
    subtract(first: number, second: number) {  
        return first - second;  
    }  
}  

Class

Reusable Component Ko Create Karne Ke Liye Class Ko Use Kiya Jaata Hai.Yah Ek Logical Entity Hai Jo Data Member Or Member Function Ke Uppar Operation Perform Karti Hai.

Examples:

class Student  
{  
    RollNo: number;  
    Name: string;   
    constructor(_RollNo: number, Name: string)   
    {  
        this.RollNo = _rollNo;  
        this.Name = _name;  
    }  
    showDetails()  
    {  
        console.log(this.rollNo + " : " + this.name);  
    }  
}  

Enum

Enum Named Constant Ka Set Hai.TS String-Based Or Numeric-Based Dono Type Ke Enums Provide Karta Hai. By Default, Enum Ke Element Ki Numbering Zero Se Start Hoti Hai, But Hum Isko Manually Update Karke Iski Setting Ko Change Bhi Kar Sakte Hai.

Also Read – TypeScript Vs JavaScript

Example:

enum Color {  
        Red, Green, Blue  
};  
let c: Color;  
ColorColor = Color.Green;  

Functions

Also Read – Typescript Data Types In Hindi

Function Ek Block Of Code Hai Jisme Hum Program Ko Organise Kar Sakte Hai.JS Ki Tarah, Typescript Bhi Dono Type Ke Function(Named Function Or As An Anonymous Function) Ko Create Karne Ke Liye Kiya Jaata Hai.Program Ko Readable, Maintainable, And Reusable Banane Ke Liye Function Kaa Use Kar Sakte Hai.

//named function with number as parameters type and return type  
function add(a: number, b: number): number {  
            return a + b;  
}  
  
//anonymous function with number as parameters type and return type  
let sum = function (a: number, y: number): number {  
            return a + b;  
};  

Also Read This Post :

Friends mujhe ummed hai ki aap TS User-Defined Data Type ko acchi tarah se samanj gye honge agar aap ko ye post acchi lage to mere is website ko jarur follow kre |

Leave a Reply

Your email address will not be published. Required fields are marked *