HomeLanguagesJavascriptTypeScript String Prototype Property

TypeScript String Prototype Property

The Prototype Property in TypeScript which is used to add properties and methods to an object. 
Syntax:

string.prototype 

Return Value: This method does not returns any value. 
Below examples illustrate the String Prototype property in TypeScript
Example 1: 

JavaScript




function Person(name:string, job:string, yearOfBirth:number)
    {    
        this.name= name; 
        this.job= job; 
        this.yearOfBirth= yearOfBirth; 
    } 
      
        
    // Driver code
    var emp = new Person("Smith", "ABC",12214) 
      
    // This will show Person's prototype property.  
    console.log(emp.prototype);


Output: 

Example #2: 
 

JavaScript




function Person(name:string, job:string, yearOfBirth:number)
    {    
        this.name= name; 
        this.job= job; 
        this.yearOfBirth= yearOfBirth; 
    } 
      
    // Driver code
    var emp = new Person("Smith", "ABC",12214) 
  
    // This will show Person's prototype property. 
    Person.prototype.email = "[email protected]"; 
       
    console.log("Person's name: " + emp.name); 
    console.log("Person's Email ID: " + emp.email);


Output: 

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32713 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
7088 POSTS0 COMMENTS
Nicole Veronica
12228 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12310 POSTS0 COMMENTS
Shaida Kate Naidoo
7203 POSTS0 COMMENTS
Ted Musemwa
7470 POSTS0 COMMENTS
Thapelo Manthata
7189 POSTS0 COMMENTS
Umr Jansen
7171 POSTS0 COMMENTS