Open In App

TypeScript String Prototype Property

Last Updated : 16 May, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

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


Output: 



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads