Objects and Prototypes

Robert Jeansoulin · 2018

JavaScript distinguishes itself from most usual “object-oriented programming”, OOP languages, which are “class based”: JavaScript is “prototype based”. This chapter presents an introduction about the notions of “concept” versus “named entities” should help in understanding the difference between “class-based” and “prototype-based” OOP. It describes the syntax and use of the “object literal” in JavaScript, popular through the Java Script Object Notation, JSON format, which is widely used to exchange data over the Internet. The chapter deals with the methods of the built-in objects “Object” and “Object.prototype”, how they provide the notion of inheritance by delegation and how objects can be related. It explores the three approaches for creating objects: literal, prototypal and classical. There are two notations to denote one particular property of an object: dot notation and bracket notation. Every object owns two types of properties: “own”, or “inherited” by delegation from one prototype of its prototypes chain.

Read the paper · More papers on PaperTik