JavaScript String prototype Property

You are Here:

JavaScript String prototype Property

The string prototype property allows you to add new properties and methods to existing object types.

Note: Prototype is a global property which is available with almost all JavaScript objects.

In the following example, we will create a seater (property) for all car (object).

Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <script> function car(brand, color) { this.brand = brand; this.color = color; } car.prototype.seater = 4; var mustang = new car("Ford", "yellow"); document.write(mustang.seater); </script> </body> </html>

Syntax

String.prototype.name = value

Reminder

Hi Developers, we almost covered 97% of JavaScript Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in JavaScript.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author