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.
Yes. Unless you can't:
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.
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:
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:
Loops handle them differently as well:
pop
and shift
usually don't leave any holes in the array, so they are less of a concern.
Glad to hear it!