Skip to Main Content
JavaScript and Open Data
book

JavaScript and Open Data

by Robert Jeansoulin
August 2018
Intermediate to advanced content levelIntermediate to advanced
272 pages
5h 3m
English
Wiley-ISTE
Content preview from JavaScript and Open Data

4Objects and Prototypes

JavaScript distinguishes itself from most usual “object-oriented programming” (OOP) languages, which are “class based”: JavaScript is “prototype based”. This originality is confusing for people accustomed to other OOP languages, and sometimes perceived as a weakness vis-à-vis better “controlled” languages such as Java, of which it “inherited” the name based on a misunderstanding.

4.1. Introduction

This chapter is organized as follows:

  • – an introduction about the notions of “concept” versus “named entities” should help in understanding the difference between “class-based” and “prototype-based” OOP;
  • section 4.2: This section details the syntax and use of the “object literal” in JavaScript, popular through the JSON format, which is widely used to exchange data over the Internet;
  • section 4.3: This section 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;
  • section 4.4: After analyzing the role of prototypes, we detail the three approaches for creating objects:
    • - literal: this includes the operator {..}, the role of the functions Object and Function, to enlighten the role of the “prototypes” in the inheritance mechanism in JavaScript,
    • - prototypal: this includes the innovative methods Object.create and Object.assign (ES6),
    • - classical: this consists of the operator “new” and the “constructor” functions.

We can hardly talk about objects ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Data Wrangling with JavaScript

Data Wrangling with JavaScript

Ashley Davis
Web Applications with Javascript or Java

Web Applications with Javascript or Java

Gerd Wagner, Mircea Diaconescu

Publisher Resources

ISBN: 9781786302045