So I felt like I had learned enough about loops to move on to something else. It’s not 100% but I’ve bookmarked the page in case I ever encounter some loops in the future to ask some more questions if necessary.
The following is a list of statements of what I understand about objects in Java Script. Please tell me whether I am wrong about the following assumptions:
a) There are six primitives data types and a 7th one: objects.
b) objects are containers, they store data or functions.
c) Variables can store objects.
d) after an object, we can use { curly braces } to designate an object literal.
e) an object literal is a list of name-value pairs. Here’s an example of an object literal:
You have an object literal composed of three different data types: string, number and boolean.
f) Key-value pair is the same thing as Name-value pair.
g) A Key-value is written like this: key: value
. An example would be like this:
Key: 'Fuel Type':
value: 'Turbo Fuel'
.
h) The key is also called the identifier.
i) If I don’t have any special character in my key, I can omit using quotation marks to indicate it’s a string.
j) Keys are also properties.
k) We use the dot operator to access to access an object’s property/key.
l) Here’s an example:
spaceship is the object, and color is one of the keys of that object.
m) We can also access an object’s property by using the bracket notation. So that’s dot operator and bracket notation as two ways to access an object’s property.
n) We do this by replacing the dot operator with brackets:
Like before, the object comes first but instead of using the .
operator we simply use brackets with the object’s property inside.
o) Brackets notations are necessary for properties which have spaces, numbers or special characters. We can’t use the dot operator to do that.
p) You can update the key-value of an object with a new value.
q) You can delete the value of a key-value with the delete
command.
r) a property is what an object has, a method what an object does.
s) console
is an object and .log
is a method for example.
t) In ES6, we can omit the colon and function
when assigning a value to a property.
u) In order to call an object’s method, we use the dot operator just like before but we add a set of parenthesis as the end this time around.
v) You need to use a comma when listing multiple methods:
w) An object can be nested with another object.
x) In fact, each property from an object literal needs to be separated with a comma for each key-value.
y) You would access a nested object like so:
1: object
2: property
3. nested property of property 2.
z) 'back-up'
here is also an object.