# Properties

## File Location

We will be working in the following file:

```
    javascript-library
        └── 0-PreWork
        └── 1-Fundamentals
            └── 10-Objects
                01-properties.js <----You will be working in this file.
```

In the pre-work, you learned about how to create an object and assign it properties. This is just a review.

## An object with no properties

```javascript
var empty_object = {};
```

## Object Literal with two properties

Look at the code below.

```javascript
var movie = {
    //These are properties
    name : "The Godfather",
    director: "Martin Scorsese"
};
```

Use . to access the properties.

```javascript
console.log(movie.name); 
console.log(movie["name"]);//No one does this, but you can.
```

```javascript
//Quotes are optional around property names
var band = {
    "name" : "Weird Al Yankovic",
    "numberAlbums": 1,
};

console.log(band.name);
console.log(band.numberAlbums);
```

## Nested properties

You also saw in the left had side module how objects can be nested. Arrays can also nested inside objects.

```javascript
var netflix = {
    id: 1,
    name: "",
    seasonInfo: {
        episodeInfo : [
            { episode: 1, episodeName: "Hey Paul"},
            { episode: 2, episodeName: "Yes Paul"}
        ]
    }
};

console.log("All data:", netflix);
console.log("Just season info: ", netflix.seasonInfo);
console.log("Episode Number: ", netflix.seasonInfo.episodeInfo[0].episode);
```

We could loop over the episode info array like this

```javascript
for (var container in netflix.seasonInfo.episodeInfo.episodeName){
    console.log(netflix.seasonInfo.episodeInfo[container].episodeName);
}
```

## Challenges

1. Create an object with several properties. Print each to the console.
2. Add an array as a property and loop over its elements. Print them to the console.
3. Recall that objects can be created from a model. Create a model asking for a person's age, height, eye color, hair color, and whether or not they wear glasses (make this a boolean value). Then create yourself as an object with that model.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://eleven-fifty-academy.gitbook.io/javascript-101-fundamentals/1-javascript-fundamentals/1-js-fundamentals/10-objects/properties.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
