Quiz

  1. Aren't bracket and dot notation interchangeable? Doesn't that make person1.age and person1[age] equivalent?

    Not quite. With square brackets, the expression is evaluated, so if it's a variable, its value is looked up. Consider:

    
        const name1 = person.name;
        const name2 = person['name'];
        const prop = 'name';
        const name3 = person[prop];
        const name4 = person['na'+'me'];
    
    

    All of the above work and do the same thing. But not this:

    
    const name5 = person[name]; 
    
    

    (Under what circumstances would name5 mean the same things as the others?)

  2. Could you explain the difference between forEach() and map()? like they both work on arrays, but differ in...

    Good question. map collects all the return values into a new array, while forEach ignores the return values (if any).

    So, you use map when you want a new array (as with the Plotting assignment or a Python list comprehension), and forEach when you just want to iterate (like a Python for loop).

  3. What are all of the uses of JSON?

    JSON is a standard way to transmit and store data. It's easily machine readable, so machine-to-machine communication is ideal. But it's also human-friendly, so it makes a good way for coders to look at data.

    So, that covers a lot of ground.

    There are whole databases designed to store data represented as JSON (so-called NoSQL databases).

  4. No questions! / Currently no, thanks!

    Great!