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

filter_none

edit
close

play_arrow

link
brightness_4
code

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);

chevron_right


Output: 



Example #2: 
 

JavaScript

filter_none

edit
close

play_arrow

link
brightness_4
code

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 = "abc@123.com"
       
    console.log("Person's name: " + emp.name); 
    console.log("Person's Email ID: " + emp.email);

chevron_right


Output: 

full-stack-img




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.