- 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?
Strings and Integers can only hold a specific type of information for example a string does not hold key/value pairs the same way as an array and to get the information from the string you would need to split or splice the string where in an array you can utilise the index to call the value.
- What variable type can be used in order to solve the problem of storing multiple values?
An Array.
- What are properties in Javascript?
Most javascript values have properties the only ones that do not are Null and Undefined, what it means is for example a string value may be “The Cat Sat” and with this value you can check properties such as length.
var string = “The Cat Sat”;
var length = string.length;
console.log(length);
Prints “11” which is a property of the value;
- Which values do not have properties?
null and undefined
- How can we access properties in a value (two ways)?
in the answer to three I have provided a way to show how a property in a value can be accessed this is by getting the variable “string” and calling the property by placing .length to it and this enables the property to be provided, another way is using square brackets on an array of data and calling the array plus square brackets enclosing an index.
- What are methods?
a method is a property that holds a function for a type of value. they are special kind of function.
- What are objects?
“Values of the type object are arbitrary collections of properties. One way to create an object is by using braces as an expression.”
- 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 are able to hold key/value pairs which enables the holding of integers, booleans, strings and arrays.
- How do you define an object?
by declaring a var and using curly braces to hold the information/data required in key/value pairs style.
- What can you say about the mutability of Javascript objects?
They are able to be changed after being defined for example with an array objects can be pushed to them, unlike some others like strings that are set to what they were originally defined as.
SECOND PART:
- Why can’t you add new properties to a string variable?
A string is immutable it can only hold the initial definition that it was provided.
- What are rest parameters?
rest parameters are able to hold all arguments they are denoted by the ellipses which is represented as three dots (…).
- (Feel free to skip the sub-chapter of Math object and Destructing)
Skipped
- What is serialisation and what is a use case of serialisation of data?
serialization means that data is converted to a flat description of itself.
- What is JSON?
JavaScript Object Notation and it is utilised in flattening data for the purposes of communicating and send data files.
- 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.”