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: 



Previous Article
Next Article

Similar Reads

Difference between Function.prototype.apply and Function.prototype.call
JavaScript treats everything as an object, even functions, and every object has its own properties and methods. Function objects have both apply() and call() methods on them. However, there is confusion about the two functions in JavaScript. The main difference between them is how they handle function arguments. There is no difference between these
2 min read
TypeScript Array.prototype.at() Method
The at() function is a feature in TypeScript that allows you to access elements in an array using positive and negative, both kinds of indices. It will return the stored value at the given index in case of a positive number and start retrieving the values from the end in the case of negative values. Syntax:array.at(index: number): T | undefinedPara
2 min read
TypeScript Array.prototype.copyWithin() Method
The copyWithin() method is available in the TypeScript Array.prototype it helps you to rearrange the elements within the array by copying a sequence of array elements. This method is good for tasks such as shifting elements, removing them without creating gaps, or copying portions of arrays. Syntaxarray.copyWithin(target, start, end)Parameters:targ
2 min read
JavaScript String prototype Property
The prototype property allows to add new properties and methods to the existing JavaScript object types. There are two examples to describe the JavaScript String prototype property. Syntax: object.prototype.name = value Return Value: It returns a reference to the String.prototype object. Example 1: This example adds a property salary to the all obj
2 min read
TypeScript | String Length Property
The Length Property() in TypeScript which is used to get the length of the string Syntax: string.length Return Value: This method returns the length to the String function that created the object. Below examples illustrate the String Length Property in TypeScript Example 1: C/C++ Code <script> // Original strings var str = "Geeksforgeeks
1 min read
TypeScript | String Constructor Property
The Constructor Property() in TypeScript which is used to returns a reference to the String function that created the object. Syntax: string.constructor Return Value: This method returns the reference to the String function that created the object. Below example illustrate the String Constructor Property in TypeScript Example 1: C/C++ Code <scri
1 min read
JavaScript Date prototype Property
The date.prototype property represents the prototype for the Date constructor. The prototype allows adding new properties, and methods. Below are examples of Date prototype Property. Example: C/C++ Code var birthday = new Date('June 21, 2018 16:44:23'); var date1 = birthday.getDate(); var day1 = birthday.getDay(); var year1 = birthday.getFullYear()
3 min read
Mongoose SchemaType.prototype.path Property
The Mongoose SchemaType.prototype.path property of the Mongoose API is used on the SchemaType object. It allows us to get the path or the field of SchemaType in the schema. It can be call on any schema object and is capable of providing path of that particular schema. Let us understand path property using an example. Syntax: schemaTypeObject.path(
3 min read
JavaScript Object.prototype.constructor Property
The constructor property returns a reference to the object constructor function that has created the instance of an object. The value of the constructor is not a string containing the function's name, but it is a reference to the function itself. Syntax: Object.constructor Return Value: It is a reference to the object of constructor. Example 1: Bel
1 min read
JavaScript Number Prototype Property
Number object in JavaScript is used to manipulate numbers whether it is negative or positive. The JavaScript Number type represents the double (fractional values) type numbers. A number literal like 98 is not an integer value but a floating-point value. It maintains the precision of 17 decimal places. 1.8 * 10^308 is the largest value it can hold,
4 min read