â Part 1 â
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?
Tracking changes in sets of values is not possible with regular single integer or string variables.
2. What variable type can be used in order to solve the problem of storing multiple values?
Arrays are a data structure that allows for the storage of multiple values.
3. What are properties in Javascript?
Properties are characteristics of some value or object, describing an attribute associated with a specific data structure.
4. Which values do not have properties?
Null and undefined do not have properties as they are nonvalues, attempting to access properties of them will return an error.
5. How can we access properties in a value (two ways)?
Properties of values can be accessed by using . or [];
let sequence = [1,2,3,4,5];
console.log(sequence.length);
console.log(sequence["length"]);
// 5
// 5
6. What are methods?
Methods are functions stored as object properties.
let list = [1, 2, 3];
//object list, an array has multiple integer values(properties).
list.push(4);
console.log(list);
//will access the values within the object and add 4 onto the end of the array and print to console.
// [1, 2, 3, 4]
list.pop();
console.log(list);
//similarly; list.pop(); will remove the last item from the list.
//[1, 2, 3]
7. What are objects?
Objects allow for the storage of not only lists of values, like arrays, but for each item within the object to have its own subset of values, properties, and methods. Thus far greater complex data structures are created.
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)?
Objects allow for greater variation in data storage and structuring, as well as their mutability enabling us to equate two object identity, not just their values as data is referenced through the object rather than the values of said objects
9. How do you define an object?
Objects can be defined with the = operator and by being contained within braces.
let aHuman = {Name: "Jack", Age:29};
console.log(aHuman);
10. What can you say about the mutability of Javascript objects?
Unlike booleans, strings, and integers, objects are mutable.
â Part 2 â
1. Why canât you add new properties to a string variable?
As they are immutable, they cannot be altered.
2. What are rest parameters?
Rest parameters allow for any number of arguments to be passed to a function as an array, allowing for easier handling of various parameters in a function.
3. What is serialization and what is a use case of serialization of data?
To reduce the clutter or code, so it is more easily transferrable, readable, and takes less memory. (Flattening) think of the difference between the two versions of jQuery.
4. What is JSON?
JavaScript Object Notation is used for data storage, sending, and receiving data over the network, as well as for Web applications.
5. What are the differences between JSON and the way programmers write objects in plain Javascript?
JSON is a text-only format to communicate between server and client, unlike Javascript which contains computation.