JavaScript String prototype Property Last Updated : 23 Jul, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 = valueReturn Value: It returns a reference to the String.prototype object.Example 1: This example adds a property salary to the all objects. html <!DOCTYPE HTML> <html> <head> <title> JavaScript String prototype Property </title> </head> <body style="text-align:center;"> <h1>GeeksForGeeks</h1> <p id="GFG_UP"></p> <button onclick="GFG_Fun();"> Click Here </button> <p id="GFG_DOWN"></p> <script> var up = document.getElementById('GFG_UP'); var down = document.getElementById('GFG_DOWN'); function person(name, age) { this.name = name; this.age = age; } var p1 = new person("p1", 24); up.innerHTML = "Click on the button to add " + "a new property to all objects of" + " a given type.< br > " + JSON.stringify(p1); function GFG_Fun() { person.prototype.salary = 1000; down.innerHTML = p1.salary; } </script> </body> </html> Output:Example 2: This example adds a method info to the all objects. html <!DOCTYPE HTML> <html> <head> <title> JavaScript String prototype Property </title> </head> <body style="text-align:center;"> <h1>GeeksForGeeks</h1> <p id="GFG_UP"></p> <button onclick="GFG_Fun();"> Click Here </button> <p id="GFG_DOWN"></p> <script> var up = document.getElementById('GFG_UP'); var down = document.getElementById('GFG_DOWN'); function person(name, age) { this.name = name; this.age = age; } var p1 = new person("p1", 22); up.innerHTML = "Click on the button to add" + " a new property to all objects " + "of a given type.< br > " + JSON.stringify(p1); function getData(name, age) { return "Information of person <br>Name - '" + name + "'<br>Age - " + age; } function GFG_Fun() { person.prototype.info = getData(p1.name, p1.age); down.innerHTML = p1.info; } </script> </body> </html> Output: Comment More infoAdvertise with us Next Article JavaScript String prototype Property P PranchalKatiyar Follow Improve Article Tags : JavaScript Web Technologies JavaScript-Questions Similar Reads 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: javascript var birthday = new Date('June 21, 2018 16:44:23'); var date1 = birthday.getDate(); var day1 = bir 3 min read JavaScript Object Prototypes JavaScript prototypes are used to access the properties and methods of objects. Inherited properties are originally defined in the prototype or parent object. The Date object is inherited from Date.prototype, Array object inherits from Array.prototype, etc. The prototypes may be used to add new prop 1 min read JavaScript Symbol toStringTag Property The Symbol.toStringTag is a well-known symbol and string-valued property in JavaScript which is used in the creation of the default string description of an object. Syntax: Symbol.toStringTagParameters: This does not take any parameter. Return value: This returns the String Object. Example 1: In thi 1 min read JavaScript Object.prototype.toString() Method In JavaScript, the Object.prototype.toString() method is used to return a string that can represent the object. The toString() method is automatically inherited by every object which is inherited from Object. Whenever an object is represented as a text value or a string is expected from the object, 3 min read JavaScript String Operators JavaScript String Operators are used to manipulate and perform operations on strings. There are two operators which are used to modify strings in JavaScript. These operators help us to join one string to another string.1. Concatenate OperatorConcatenate Operator in JavaScript combines strings using 3 min read Like