Quiz
- 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:
All of the above work and do the same thing. But not this:
(Under what circumstances would
name5mean the same things as the others?) - Could you explain the difference between forEach() and map()? like they both work on arrays, but differ in...
Good question.
mapcollects all the return values into a new array, whileforEachignores the return values (if any).So, you use
mapwhen you want a new array (as with the Plotting assignment or a Python list comprehension), andforEachwhen you just want to iterate (like a Pythonforloop). - 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).
- No questions! / Currently no, thanks!
Great!