Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To extract a single value type from a nested object, you can use the dot notation or bracket notation to access the specific nested property that contains the value. For example:

const nestedObject = {
  person: {
    name: "John",
    age: 30
  }
}

// Dot notation
const name = nestedObject.person.name;
console.log(name); // "John"

// Bracket notation
const age = nestedObject["person"]["age"];
console.log(age); // 30

In this example, we use the dot notation and bracket notation to access the name and age properties from the person nested object. The extracted values can then be used in further computations or as needed.