Part I
- What problems does this chapter introduce that cannot be solved with variable types such as strings or integers?
Variable types such as strings or integers hold an unique value. The chapter introduces data structures such as objects and arrays that can store sequence or group of values in one single binding.
- What variable type can be used in order to solve the problem of storing multiple values?
We can use Arrays that can be used to store a sequence of values or Objects that can group different types of values.
- What are properties in Javascript?
Properties are the values associated with a JavaScript object, and can usually be changed, added, or deleted. Object properties can be both primitive values, other objects, and functions.
- Which values do not have properties?
In JavaScript only ânullâ and âundefinedâ doesn´t have properties.
- How can we access properties in a value (two ways)?
We cand access properties in JavaScript with a dot or with square brackets.
When using a dot, the word after the dot is the literal name of the property.
Ex.: objectName.property)
When using square brackets, the expression between the brackets is evaluated to get the property name.
Ex.: objectName[âpropertyâ]
- What are methods?
Methods are object properties that contain a function definition.
Ex.: objectName.method()
- What are objects?
Objects are arbitrary collections of properties.
âWe can imagine an object as a cabinet with signed files. Every piece of data is stored in its file by the key. Itâs easy to find a file by its name or add/remove a file.â
- 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 hold many different types of values in one binding making programming more efficient since we can wrap all this datatypes together instead of storing them separately.
- How do you define an object?
We define an object using figure brackets with an optional list of properties separated by commas inside them. Each property has a name followed by a colon and a value. Ex.:
var object = { property1: value1, property2: value2 }
- What can you say about the mutability of Javascript objects?
Objects are mutable in JavaScript since their state can be modified after we create them, causing a single object could have different types of data at different times.
Part II
- Why canât you add new properties to a string variable?
In JavaScript we can´t create a property on primitive values such as a string, a symbol, a number or a boolean since they are immutable and cannot be changed.
- What are rest parameters?
Rest parameters are dynamic parameters that capture all the values passed to them, allowing us to more easily handle various inputs as parameters in a function and call this function with any number of arguments.
function fxname(âŚrestParameter){ statement; }
- What is serialisation and what is a use case of serialisation of data?
Serialisation is the process of converting data into a flat description or a sequence, for storing or transporting data proposes, from which it can later be restored.
- What is JSON?
JSON stands for âJavaScript Object Notationâ, and it´s a popular format for serialised data often used when data is sent from the server to a web page.
- What are the differences between JSON and the way programmers write objects in plain Javascript?
In JSON 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). Also, comments are not allowed in JSON.