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 3 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 →

Web Component Development with Modern Libraries and Tooling

A wrec component property whose value is defined by an expression and recomputed when its dependencies change.

How it is used
Calculates derived component values that should refresh when their input properties change.
How deep it goes
Explains declaration, recomputation, and alternatives, but does not detail the runtime dependency-tracking internals.
Examples
Uses width and height sliders to compute and display a rectangle area.
What you can do after
Apply it via wrec by declaring a computed property and displaying its value in component markup.

Read how Web Component Development with Modern Libraries and Tooling explains computed property →

Also covered in

Related concepts

Questions about computed property

What is computed property?

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

Which Manning books explain computed property?

Secrets of the JavaScript Ninja, Second Edition, Building User-Friendly DSLs and Web Component Development with Modern Libraries and Tooling.

What is the difference between computed property and computed property name?

A computed property is a property whose value is derived from other data when accessed rather than stored as an independent value. A computed property name is a syntax form in which an object or class property key is determined by evaluating an expression.

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.