liveBook · Manning

Computed property

A computed property is a property whose value is derived from other data when accessed rather than stored as an independent value.

How 2 Manning books explain it

Secrets of the JavaScript Ninja, Second Edition

A property whose value is derived on access or assignment rather than stored as an independent data field.

How it is used
Represents a value derived from object state as a property accessed through a getter and, optionally, changed through a setter.
How deep it goes
Explains getter concatenation and setter splitting into underlying properties, covering both reads and writes.
Examples
Uses a shogun’s fullTitle, derived from name and clan and assigned by splitting a title string.
What you can do after
Evaluate/understand how to expose derived object state as a property and map assignments back to its component properties.

Read how Secrets of the JavaScript Ninja, Second Edition explains computed property →

Building User-Friendly DSLs

A class property whose value is derived when accessed rather than stored as an independently assigned value.

How it is used
Derives a read-only rental amount for display while reflecting changes to rental price and discount inputs.
How deep it goes
Defines JavaScript getters, demonstrates placeholder and final formulas, and connects access to formatted JSX output.
Examples
Uses Rental, rentalPriceBeforeDiscount, discount, rentalPriceAfterDiscount, and a formatted rental form field.
What you can do after
Apply it via a JavaScript getter to derive and display a rental amount without accepting direct edits.

Read how Building User-Friendly DSLs explains computed property →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.