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: