1. 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?
We need to store multiple values in a variable.
2. What variable type can be used in order to solve the problem of storing multiple values?
An array.
3. What are properties in Javascript?
Properties are the values associated with a JavaScript object.
4. Which values do not have properties?
null and undefined. If you try to access a property on one of these nonvalues, you get an error.
5. How can we access properties in a value (two ways)?
The two main ways to access properties in JavaScript are with a dot and with square brackets. Both value.x and value [ x] access a property on value. But not necessarily the same property.
6. What are methods?
Properties that contain functions are generally called methods of the value they belong to.
7. What are objects?
Values of the type object are arbitrary collections of properties.
8. 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)?
They can hold many values of different datatypes.
9. How do you define an object?
By using braces as an expression. Inside the braces, there is a list of properties separated by commas. Each property has a name followed by a colon and a value.
10. What can you say about the mutability of Javascript objects?
You can change their properties, causing a single object value to have different content at different times.
Part 2
1. Why can’t you add new properties to a string variable?
Values of type string, number, and Boolean are not objects, and though the language doesn’t complain if you try to set new properties on them, it doesn’t actually store those properties. As mentioned earlier, such values are immutable and cannot be changed.
2. What are rest parameters?
It can be useful for a function to accept any number of arguments. To write such a function, you put three dots before the function’s last parameter. When such a function is called, the rest parameter is bound to an array containing all further arguments.
4. What is serialisation and what is a use case of serialisation of data?
That means it is converted into a flat description. If you want to save data in a file for later or send it to another computer over the network, you have to somehow convert these tangles of memory addresses to a description that can be stored or sent.
5. What is JSON?
Stands for JavaScript Object Notation.
6. What are the differences between JSON and the way programmers write objects in plain Javascript?
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.