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 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 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 How to create an object with prototype in JavaScript ? In this article, we will discuss object creation & prototypes, along with understanding the different ways for object creation & their implementation through the examples. Prototypes are the mechanism by which objects in JavaScript inherit features from another object. A prototype property i 4 min read Difference Between Objects and Prototypes in JavaScript Objects in JavaScriptThe Objects in JavaScript are instances of the class or constructors and they can hold properties and methods. These properties and methods can be unique to the object or inherited from the prototypes. The Objects can be created using the constructor functions, object literals, 3 min read Prototype Method - JavaScript Design Pattern A Prototype Method is a JavaScript design pattern where objects share a common prototype object, which contains shared methods. The prototype method allows you to reuse the properties and methods of the prototype object, and also add new ones as needed. The prototype method is useful for performance 3 min read How does JavaScript .prototype work ? In JavaScript when adding behaviour to objects, then if creating multiple objects using the constructor (calling the constructor function with the 'new' keyword) then the new keyword is the one that is converting the function call into constructor call and every time a brand new empty object is crea 4 min read Like