liveBook · Manning

Person object

As explained in Functional Programming in JavaScript

An object representing a person in the book's examples, with properties such as fullname and address.city.

A Person object represents one person through properties such as fullname, address, and birthYear. Collections of these objects make familiar data-processing operations concrete: extracting names, grouping locations, counting countries, and selecting people born in a particular year. section 3.3

Creating and reading person objects

Four objects are created with Person and Address constructors, then stored in an array. A small arrow function extracts a name: const name = p => p.fullname; console.log(name(p1)); // 'Haskell Curry'. The same collection can be mapped, reduced, or filtered using properties such as address.country and birthYear. section 3.3

const p1 = new Person('Haskell', 'Curry', '111-11-1111');
p1.address = new Address('US');
p1.birthYear = 1900;

const p2 = new Person('Barkley', 'Rosser', '222-22-2222');
p2.address = new Address('Greece');
p2.birthYear = 1907;

const p3 = new Person('John', 'von Neumann', '333-33-3333');
p3.address = new Address('Hungary');
p3.birthYear = 1903;

const p4 = new Person('Alonzo', 'Church', '444-44-4444');
p4.address = new Address('US');
p4.birthYear = 1903;

Browse the concrete Person and Address instances, including names, countries, and birth years. section 3.3

How Functional Programming in JavaScript covers it

How deep it goes
Shows construction, property access, nested address data, and collection transformations without developing a formal object model.
Examples
Uses four named people with countries and birth years to extract names, count countries, and select people born in 1903.
What you can do after
Apply JavaScript collection operations to person records by reading properties and composing transformations.
How it connects
Connects Person objects to arrays, arrow functions, map, reduce, filter, grouping, and nested data access.

This explainer was generated by Manning's knowledge graph from the text of Functional Programming in JavaScript. The section links point to the parts of the book it draws on.