What are advanced objects?

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.

9 Likes

did you mean to type ‘let person’

8 Likes

@edensjasmine That’s probably what he meant to type but the variable name you use doesn’t matter as long as you maintain uniformity by using it throughout your code.

11 Likes

Great! Reading this, I understood advanced objects even before taking the Codecademy course. Great one axelban.

12 Likes

I know, right! Haha

I came here after reading the intro, but this felt like much more understandable compared to the actual intro. Nice work, @axelkaban

5 Likes

Wow! Great explanation buddy! I have not done the lessons yet, but you introduced me best to what I have to expect! :slight_smile:

3 Likes

Hello, Axelkaban.

I noticed an extra curly brace after the end of the “isAdvisor” property, however; looks like a typo. Otherwise, appreciate the clarification.

-Ed

4 Likes

That was more clear of an explanation than the lesson gave and what a great example. Thank you it really hit it home for me.

1 Like

Funny you didn’t notice - ```
isAdvsor: true