• I thought that we had to add () when referencing an object? In the previous question I chose person1.age but i thought it would be person1.age() ?

    parens are for invoking a function. While it's possible that person1.age is a function that needs to be invoked, it's more likely to be a number.

    In the question, I said it was a property, so we just look up the property using a dot. If the property happened to be a function, we could invoke it, but I didn't ask you to.

  • Should we always use dot notation?

    Yes. Unless you can't:

    
        var class_dict = {hermione: {hair: 'bushy brown', pet: 'Crookshanks'},
                          harry: {hair: 'black', pet: 'Hedwig'},
                          ron: {hair: 'red', pet: 'Scabbers'}};
        var name = prompt('person to look up? ');
        var person = class_dict[name];          // can't use dot here
        console.log(person.hair, person.pet);   // can use dot here
    
    
  • I would like to talk more about Unknown Properties.

    It just means that the programmer doesn't know what the key is when they are writing the program. An example is the previous case, where we are looking up a student in the class dictionary.

  • I am confused about the syntax of using object.keys for unknown properties and where each part of the syntax comes from.

    Good question. The Object.keys() function is similar to the Python .keys() method: it returns a list of the keys of the dictionary.

    Given the class_dict above, we can get a list of students in the class like this:

    
        var students = Object.keys(class_dict);
        console.log(students);
        students.forEach(name => {
            let s = class_dict[name];
            console.log(`${name} has ${s.hair} hair and owns ${s.pet}`);
        });
    
    
  • Do we never delete data in an JavaScript Object? Does the array methods like pop and shift works when removing data in objects as well?

    It's rare to delete data, so while it's good to know about, it's less important .

    Array methods handle missing elements in different ways:

    
        var scores = [ 91, 88, 72, 85, 92 ];
        delete scores[2];          // drop the 72
        y = scores.map(n => n+1);  // generates missing element
        scores.forEach(n => console.log(n));  // skips missing element
    
    

    Loops handle them differently as well:

    
    for( i in scores ) { console.log(scores[i]); }
    for( i = 0; i < scores.length; i++ ) { console.log(scores[i]); }
    
    

    pop and shift usually don't leave any holes in the array, so they are less of a concern.

  • The reading is straightforward. Since JavaScript is similar to Java I'm able to understand the syntax! / the reading made sense

    Glad to hear it!