The sub-chapter called - The weresquirrel. What problems does this chapter introduce that cannot be solved with variable types such as strings or integers?**
The problem is, strings and integers, by themselves, are too limited to solve this problem. It requires more complicated types of data.
What variable type can be used in order to solve the problem of storing multiple values?
The Object variable, which can store complex data structures
What are properties in Javascript?
Properties are the values associated with a javascript object. They are usually changeable (mutable)
Which values do not have properties?
null and undefined
How can we access properties in a value (two ways)?
A dot followed by property name such as .length
For an array, square brackets and index number such as [5]
What are methods?
Methods are functions that extract object properties using the syntax objectName.methodName() and an example being stringName.toUpperCase()
What are objects?
‘JavaScript objects are containers for named values, called properties and methods’ (quoted from W3Schools.com)
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 can contain multiple data types (as well as their methods)
How do you define an object?
the simplest way is as an object literal such as:
var person = {firstName:”Mary”, lastName:”Riley”, age:”35”, height:”170cm”, sex:”female”}
What can you say about the mutability of Javascript objects?
The values held within javascript objects can be changed ie the value attribute can be changed (assuming it is writable)
SECOND PART:
Why can’t you add new properties to a string variable?
A string variable is not an object. It is immutable.
What are rest parameters?
These allow an unspecified number of arguments (as an array)
What is serialisation and what is a use case of serialisation of data?
It is the process of converting the name:value pairs of an object to a string by using methods such as JSON.stringify() and JSON.parse()
This process converts data into a form that can be more easily transferred over a network, or stored in an array or some sort of file (such as .csv)
What is JSON?
JavaScript Object Notation, commonly used for transferring data over the Web. It is replacing XML in this respect.
What are the differences between JSON and the way programmers write objects in plain Javascript?
Property names are surrounded by double quotes. Only simple data expressions are allowed, and comments are not allowed.