JavaScript Object Prototypes Last Updated : 26 Jul, 2023 Comments Improve Suggest changes Like Article Like Report 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 properties and methods to the existing objects and object constructor. Syntax: Object.prototypeExample 1: This example adds a new property to the object. JavaScript function Student(a, b) { this.name = a; this.id = b; } Student.prototype.age = 12; const s1 = new Student("Dinesh", 1234567); console.log(s1.name + " is " + s1.age + " years old."); OutputDinesh is 12 years old.Example 2: This example adds a new method to the object. JavaScript function Student(a, b) { this.name = a; this.id = b; } Student.prototype.details = function () { return this.name + " " + this.id }; let s1 = new Student("Dinesh", 1234567); console.log(s1.details()); OutputDinesh 1234567 Comment More infoAdvertise with us Next Article JavaScript Object Prototypes R riarawal99 Follow Improve Article Tags : JavaScript Web Technologies javascript-object Similar Reads JavaScript Prototype In JavaScript, everything is an object, including functions, arrays, and strings, which are specialized types of objects. JavaScript follows a prototype-based system, where objects inherit properties and methods from other objects through prototypes. This prototype mechanism plays a key role in how 9 min read JavaScript Object setPrototypeOf() Method The Object.setPrototypeOf() method in JavaScript is a standard built-in object thatthat will sets the prototype (i.e., the internal [[Prototype]] property) of a specified object to another object or null.Syntax:Object.setPrototypeOf(obj, prototype)Parameters:This method accepts two parameters as men 2 min read JavaScript Objects In our previous article on Introduction to Object Oriented Programming in JavaScript we have seen all the common OOP terminology and got to know how they do or don't exist in JavaScript. In this article, objects are discussed in detail.Creating Objects:In JavaScript, Objects can be created using two 6 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 = valueReturn Value: It returns a reference to the String.prototype object.Example 1: Th 2 min read JavaScript Object Reference JavaScript Objects are the most important data type and form the building blocks for modern JavaScript. The "Object" class represents the JavaScript data types. Objects are quite different from JavaScriptâs primitive data types (Number, String, Boolean, null, undefined, and symbol). It is used to st 4 min read Like