1 - What problems does this chapter introduce that cannot be solved with variable types such as strings or integers?
For the purpose of storing a bunch of data, it is much more practical to store it in a data structure.
2. What variable type can be used in order to solve the problem of storing multiple values?
Arrays like so:
let myArray = [5, 2, 7, 9];
3. What are properties in Javascript?
Properties are characteristics of values in a data structure. for example:
let myArr = [4, 2, 5, 7, 3];
console.log(myArr.length);
in this case: myArr.length is an expression which points to myArr (the array i declared) and the .length (is the method used to get the maximum number of indexes within myArr).
4. Which values do not have properties?
Null and undefined.
5. How can we access properties in a value (two ways)?
value.x
value[x]
6. What are methods?
Properties that contain functions for example the .toUpperCase(); method
7. What are objects?
data structures like objects are used to store 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 solve the need to store different data types.
9. How do you define an object?
one declares a variable but the difference is that the value of that variable has to be inside curly braces {}, inside the curly braces one must separate the properties using commas, each of the properties should be given a name followed by a colon and a value. example
let myObj = {
horse: false,
events: ["gym", "eat", "coding", "eat", "eat again"]
};
10. What can you say about the mutability of Javascript objects?
mutability as the name suggest is the characteristic of a datatype that allows it to be changed or modified after it has been declared.
objects are mutable.
strings, numbers, booleans are immutable.
SECOND PART
1. Why canât you add new properties to a string variable?
because strings are immutable.
2. What are rest parameters?
they represent an array with all arguments that will be included and are called by writing three dots before the functions name.
3. What is serialisation and what is a use case of serialisation of data?
To serialize data is to flatten the description of the data.
4. What is JSON?
JSON is a popular serialization format, it stands for JavaScript Object Notation, it is ised as a data storage and communication format on the Web and even for other lenguages.
5. What are the differences between JSON and the way programmers write objects in plain Javascript?
JSON looks the almost the same as plain JavaScript but with the following restrinctions:
-
- All property names must be surrounded by double quotes, only simple data expressions are allowed.
-
- no function calls
-
- no bindings
-
- anything that involves actual computation
-
- comments are not allowed.