- Read the sub-chapter called The weresquirrel. What problems does this chapter introduce that cannot be solved with variable types such as strings or integers?
This sub-chapter introduces need for data structure, to group variables into into one pool which will help us work with it.
- What variable type can be used in order to solve the problem of storing multiple values?
An array can store multiple values.
- What are properties in Javascript?
These are expressions that access a property of some value.
- Which values do not have properties?
Null and undefined.
- How can we access properties in a value (two ways)?
By using dots or square brackets.
- What are methods?
Properties that contain functions.
- What are objects?
Collection of properties.
- What problem do objects solve that cannot be solved with other value types weâve learned so far (such as integer, string, array, boolean etc)?
Can assign multiple variables as arrays, int, string etc. in one piece/variable.
- How do you define an object?
One way to create an object is by using curlybraces as an expression.
let computer = {
desktop: true,
insideComponents: ["motherboard", "RAM", "processor"],
outsideComponents: ["monitor", "mouse", "keyboard", "wires"]
};
Second way it by creating an array as a kind of object
let smartphone = [
{specs: ["8 GB RAM", "Android", "64 GB Space"],
used: false},
{specs: ["6 GB", "Android", "128 GB Space", "Super AMOLED"],
used: true},
{specs: ["8 GB RAM", "iOS"],
used: false},
/* and so on... */
];
- What can you say about the mutability of Javascript objects?
It is about references. If we have two objects with the same reference in memory, changing values inside one of them will affect the values for the second, because they both reference to the same place in memory.
If we have two objects and they have different references, even they would have the same content, they would not be consider as the equal.
Second Part:
- Why canât you add new properties to a string variable?
Values of type string, number, and Boolean are not objects, such values are
immutable and cannot be changed, it doesnât actually store those new properties.
However these types do have built-in properties.
- What are rest parameters?
It enables a funtion to accept any number of arguments.
-
(Feel free to skip the sub-chapter of Math object and Destructing)
-
What is serialisation and what is a use case of serialisation of data?
When exchanging data between a browser and a server, the data can only be text and that is why we are using serialisation. It is the process of translating data structures or object state into a format that can be stored or transmitted and reconstructed later (possibly in a different computer environment).
- What is JSON?
JSON is text, and we can convert any JavaScript object into JSON, and send JSON to the server.
We can also convert any JSON received from the server into JavaScript objects.
This way we can work with the data as JavaScript objects, with no complicated parsing and translations.
- What are the differences between JSON and the way programmers write objects in plain Javascript?
JSON looks similar to JavaScriptâs way of writing arrays and objects, with a few restrictions. All property names have to be surrounded by double quotes, and only simple data expressions are allowedâno function calls, bindings, or anything that involves actual computation. Comments are not allowed in JSON.