What are advanced objects?


#1

Question

What’s the difference between advanced objects and how we have been making them?

Answer

Advanced objects are not a different type of object, they are mentioned as advanced, because of the advanced features we can implement to our objects. For example, we can build an object like so:

let peson = {
  name: 'Axel',
  location: 'US',
  isAdvsor: true
}

But what if we wanted to create many people, doing it one by one will be tiresome, so an advanced feature we can use is the Factory function and it can purposely be created to make objects, ie.:

const makeCodecademyPeople = (name, location, isAdvisor) => {
  return {
    name,
    location,
    isAdvisor
    }
	};
};

//now, calling the function will create a new object that we can assign to 
//a variable:
let axelAdvisor = makeCodecademyPeople('Axel', 'US', true);

console.log(axelAdvisor.name) //Axel

note: I used another advanced feature for objects called property value shorthand which is part of destructuring.

In the end, what is advanced is the tools that we are learning to improve how we interact and build objects.