Skip to content
Related Articles
Get the best out of our app
GFG App
Open App
geeksforgeeks
Browser
Continue

Related Articles

TypeScript String Prototype Property

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

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: 


My Personal Notes arrow_drop_up
Last Updated : 16 May, 2022
Like Article
Save Article
Similar Reads
Related Tutorials