Data Structures (Arrays and Objects) - Reading Assignment

  1. To solve the problem described in sub-chapter The weresquirrel, requires to store and organised multiple values in structural way.
  2. Arrays is used to store multiple values in a single variable.
  3. Almost all variables in Java Script have a properties. Properties are the values associated with a Java Script object.
  4. Null and undefined.
  5. You can access it using dot . or brackets [] after the object. (array.length or array[length].
  6. Methods are the properties which contains function.
  7. Object is a collection of properties.
  8. It’s allows to assign bunch of different type of properties comprising of different variables like boolean, array, interger and ect. to a single object.
  9. Object in Java Script is defined with braces. Inside the braces, there is a list of properties separated by commas. Each property has a name followed by a colon and a value.
  10. Objects properties can be changed, causing a single object value to have different content at different times.

SECOND PART:

  1. A strings are immutable, since they are not objects.
  2. Rest parameters allows to use an argument in a function.
  3. Serialisation is a conversation of stored data in the memory to a flat description. Its used to move data around (saving, downloading and ect.)
  4. JSON is a serialization format.
  5. 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.
1 Like

What problems does this chapter introduce that cannot be solved with variable types such as strings or integers?

Sometimes we need to work with complex data structures and sequences and while we can use string objects and variables to do this sort of work it can be very tricky because iterating through long strings is complex and they don’t have methods associated with them to make a task like this easy. Similarly with integers. Integers would have to be converted to strings and problems like this can become extremely difficult using just these types of data structures.

What variable type can be used in order to solve the problem of storing multiple values?

The array object type can be used to sequences and key pair values.

What are properties in Javascript?

Properties could be described as expressions which can be used to access the property of some value like for example the String object which has a property called .length which when called will return the length of a string as an integer.

Which values do not have properties?

The values null and undefined have no properties.

How can we access properties in a value (two ways)?

The two ways we can access properties in a value are

  1. if we use the dot syntax and say for example String.length
  2. if we use its label will work the same for example String[“length”]

What are methods?

Methods are properties that contain function values such as Array.slice() which will copy a section of an array.

What are objects?

Objects could be described as collections of properties which describe the object as a whole. There are many different types of objects from string objects, math objects, array objects and even function objects.

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)?

Fixed value types are immutable and as we have been discussing sometimes we need more complex data structures to represent all the data we wish to work with. Objects solve this problem because they are not fussy about the data they store and one can insert pretty much any type of value into an object.

How do you define an object?

There are a number of ways to define an object such as using the new keyword for example

      myObject = new Array("item1", "item2", "item3")

or

      earth = new Array()
      earth.diamater = "big"
      earth.distance = "92 million miles"
      earth.day         = "24 hours"

What can you say about the mutability of Javascript objects?

JavaScript objects are considered to be mutable in that their properties can be changed and look different at different times unlike integers, strings and Boolean’s which are considered immutable.

SECOND PART:

Why can’t you add new properties to a string variable?

A string variable is immutable and thus cannot have new properties attached to it. You could assign a new property to a string variable and javascript wont complain but it will ignore your efforts to access it.

What are rest parameters?

Rest parameters are inserted into the parameter list of a function. They are represented by 3 dots. They indicate that the following arguments are bound to an array. any preceding parameters are ignored.

(Feel free to skip the sub-chapter of Math object and Destructing)

I had a read of it…

What is serialization and what is a use case of serialization of data?

Serialization of data is the conversion of data into a flat structure. We serialize data to make it more portable and easier to transfer.

What is JSON?

JSON stands for JavaScript Object Notation and is a method for serialization of object data.

What are the differences between JSON and the way programmers write objects in plain Javascript?

The differences between JSON and JavaScript are

JSON has

  1. All properties are surrounded in double quotes.
  2. Only simple data expressions allowed
  3. No function calls.
  4. No bindings.
  5. No actual computation.

JavaScript has

  1. stringify
  2. parse
    to assist in working with JSON files.
1 Like
1. The need to have Data structures to organize complex sets of data cannot be done using simple/pure strings or integers.
2. Multiple values can be stored in Array or Object type variables.
3. Properties are special names or indexes in an Object/Array type variables that hold values or methods.
4. Values null and undefined do not have properties
5. One can access a value of a propertyName in an Object/Array variable using one dot ".propertyName" or inside square brackets "[propertyName]" after the varName like this:  varName.propertyName == varName[propertyName] //true
6. A method is a function 'value' stored in a Property.
7. Objects are collections or sets of key:value pairs, or Properties, separated by commas, inside curly brackets, that are useful to structure an application data for best data usage and manipulation.  Example: let aJSObject = { aKeyNumber: 1, aKeyString: "value as a string"}.
8. In an object type we can 'structure' a mix of different value-types using different properties/keys and as values from all sorts of value-types from primitive types to arrays and even to other objects
9. An object is a memory-block holding a structured collection/set of properties key-value data
10. Mutability of Javascript objects means that the contents of properties key-data hold of the object variable "instance" may be changed by the program handling the object

Second part:

1. because strings are "immutable", or in other words, strings are not objects in JavaScript and therefore cannot be extended with 'extra' properties other than the ones designed in each JavaScripts/ECMAScript version specifications
2. rest parameters use tree dots and a name "...restParams" they allow conversion of unknow length/amount of parameter value sequences into an array of values and vice-versa
3. I felt free to read it also, ok
4. Serialization is the method required to format or code the current object-instance data for being able to be uniquely distinguish after transmission or storage into another device or machine, example to store objects in a disk file or inside a database record or field
5. JSON is JavaScript Object Notation, and is a ready to use object 'serialization' friendly notation that is available in JavaScript and used even elsewhere in other languages
6. JSON format all properties keys must be also double-quoted, values must be pure values and can not be dynamic expressions or function calls, so JSON is always a ready known "finish" notation of all the object instance current keys and values stored.

Boy @ivan this was really a very long test
I whish next chapters be more distributed in lower granularity exercises

1 Like

Excellent answer sir! really well documented! keep it like that please! :muscle:

Carlos Z

1 Like

Here’s the answer to the Q.8 which I forgot to answer.

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 in JavaScript solve the problem of returning different property values as its defined as an unordered collection of related data, of primitive or reference types, in the form of “key: value” pairs. These keys can be variables or functions and are called properties and methods, respectively, in the context of an object. Unlike arrays can only store one type of value & return the same.

1 Like

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?
Strings or integers cannot store than multiple values, so those values cannot be recalled either.

2. What variable type can be used in order to solve the problem of storing multiple values?
Array

3. What are properties in Javascript?
They are the values associated with JavaScript objects.

4. Which values do not have properties?

null and undefined

5. How can we access properties in a value (two ways)?

objectName.property / objectName["property"]
ie: var arry = [0,1,2,3,4]
console.log(arry.length)
>> 4
console.log(arry["length"])
>> 4

6. What are methods?
They are properties that contain functions

7. What are objects?
It is an agglomeration of unordered 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)?
It can hold varieties of datatypes

9. How do you define an object?

var car={Type:Sudan, Year:2002, Manufacturer: BMW};

10. What can you say about the mutability of Javascript objects?
Properties values can be change outside the object defined, so these objects are mutable.

SECOND PART:

1. Why can’t you add new properties to a string variable?
the values in a type string are immutable

2. What are rest parameters?
They are additional arguments given to a function.

3. (Feel free to skip the sub-chapter of Math object and Destructing)

4. What is serialisation and what is a use case of serialisation of data?
Serialisation is the process of converting object state/ data structures into a format that can be stored.
The use of serialisation is to save data in a file or send it to another computer over a network.

5. What is JSON?
JSON, also know as JavaScript Object Notation.
It is a popular serialisation format.

6. What are the differences between JSON and the way programmers write objects in plain Javascript?
JSON is basically a text only format that is used to communicated between server and client, whilst javascript is able to be interpreted by mostly any browsers

1 Like
  1. What problems does this chapter introduce that cannot be solved with variable types such as strings or integers?
    A way to store several an possibly different kinds of values in a single value.

  2. What variable type can be used in order to solve the problem of storing multiple values?
    Arrays and objects (array is also a type of object.

  3. What are properties in Javascript?
    Properties are a kind of named values (key:value-pairs) belonging to objects.

  4. Which values do not have properties?
    Null and undefined.

  5. How can we access properties in a value (two ways)?
    Dot notation or bracket notation – object.proterty or object[indexOfProperty].

  6. What are methods?
    Functions that operate on objects.

  7. What are objects?
    A datatype with named properties, including functions.

  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)?
    We need objects to store values of named properties that also can be changed. Simple datatypes are immutable, their values cannot be changed.

  9. How do you define an object?
    let object = {key1:value1, key2:value2, …};

  10. What can you say about the mutability of Javascript objects?
    Well, objects are mutable, they have values that can change. Even objects declared with const can have its properties changed.
    SECOND PART:

  11. Why can’t you add new properties to a string variable?
    Strings are immutable, their values cannot change.

  12. What are rest parameters?
    A way to use an unknown number of parameters in a function. They’re declared with three dots in front of the parameter name: (…parameter).

  13. (Feel free to skip the sub-chapter of Math object and Destructing)
    4. What is serialisation and what is a use case of serialisation of data?
    Serialisation is to make sure tasks are done in a certain order, one task after another. By serialising data we can converted it into a flat description, and we can create standard data formats that we can interchange between computer systems.

  14. What is JSON?
    JavaScript Object Notation. It’s a standardised way of collecting and exchange data between computer systems.

  15. What are the differences between JSON and the way programmers write objects in plain Javascript?
    Mostly just a syntactical differens, but property names have to be written with double quotes,
    and only simple data expressions are allowed. JSON objects cannot have function calls, bindings, or
    anything that does computation, and there’re no comments in JSON.

1 Like

Part 1. Chapter 4. Arrays and Objects.

  1. A variable type which can store multiple values and have ease of access.
  2. Arrays.
  3. Properties define some characteristic about the values in a data structure. (e.g. the index of a value)
  4. Null and Undefined.
  5. Use . (dot) and [ ] (square brackets) notations.
  6. Methods are properties that hold function values. (e.g. .push method adds values to the end of an array.)
  7. Objects are values of arbitrary collections of properties.
  8. An object can hold different data types (e.g. integers, booleans, strings, and arrays.)
  9. In this example, faveSneakers would be the object and it is defined with the following syntax:
    let faveSneakers = { color: “black”, size = 11, brand: “addidas”}; Note the properties (color, brand, and size) are followed by a colon and a value.
  10. They can be modified. (e.g. properties of JavaScript objects ARE mutable.) For example, if Nike were my new faveSneakers, the brand property from “addidas” can be reassigned to “Nike” in the previous answer.

Part 2.

  1. Strings are immutable. Values of type string, number, and Boolean are not objects, and though the language doesn’t complain if you try to set new properties on them, it doesn’t actually store those properties. As mentioned earlier, such values are immutable and cannot be changed.
  2. Rest Parameters represent an array with all the arguments that will be included. When certain functions are called, the rest parameter is bound to an array containing all further arguments. If there are other parameters before it, their values aren’t part of that array. When, as in max , it is the only parameter, it will hold all arguments.
  3. serialize the data. That means it is converted into a flat description for transferability/compatibility.
  4. JavaScript Object Notation (pronounced “Jason”). A data storage and communication format on the internet.
  5. 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.
1 Like

Welcome to the discussion about the reading assignment about data structures.

Leave your answers to the questions below in this thread. If you have any questions or you want to discuss something connected to the assignment feel free to do it in this thread as well, but please everything to the topic.

  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?
    -Create a data structure to store sequences of information/values
  2. What variable type can be used in order to solve the problem of storing multiple values?
  • An Array and objects
  1. What are properties in Javascript?
  • Values of an object
  1. Which values do not have properties?
  • Null and undef
  1. How can we access properties in a value (two ways)?
  • with dot “.” or “[ ]” Brackets
  1. What are methods?
    Functions in an objects
  2. What are objects?
  • A variable that holds values and properties and acts like a unit
  1. 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 all the different variable types if needed and all values are able to be changed when needed.
  1. How do you define an object?
    With closed curly brackets
  • let object1 = {value: 10};
  1. What can you say about the mutability of Javascript objects?
  • objects can be manipulated after being created. You can change their properties unlike strings.

SECOND PART:

  1. Why can’t you add new properties to a string variable?
  • Values of type string, number and boolean are not objects and are immutable.
  1. What are rest parameters?
  • Allows us to represent endless number of arguments as an array
  1. (Feel free to skip the sub-chapter of Math object and Destructing)
  2. What is serialisation and what is a use case of serialisation of data?
  • Conversion of saved data into network readable data for transfer.
  1. What is JSON?
  • javascript is Javascript Object Notation, a simplified version readable by many languages.
  1. What are the differences between JSON and the way programmers write objects in plain Javascript?
    JSON has double quotes and unlike Javascript it can only run simple expressions, no bindings, functions or comments.
1 Like
  1. JS goes beyond a single variable binding to a single integer or a single string by binding the variable to an array which are multiples of integers, characters, or a combination thereof. Technically all variables are array variables but what this chapter is introducing are variables that bind multiple elements whichcis a grand leap from simple data to group data structure, a higher degree of complexity.

  2. The variables that deal with data sets are called arrays. Each unit of an array variable are called ‘elements’.

  3. Properties are subroutines that follow the ‘.’ of the variable and their function is to parse what they were programmed to do from the array variable (redundant to say variable). For example a .max property parses the array for the element of the highest value.

  4. The values null and undefined actually are ‘non-values’ and as such cannot have properties as they do not hold anything at all, they are void aka empty…there is nothing to be retrieved from them. ‘Does not compute’ if you will.

  5. I could be wrong here but here is my best guess from my interpretation of the text. Array elements are indexed with integers from 0 to whatever. Each indexed integer corresponded to an element value that may be an integer or characters. For example the symbol ‘1’ can be interpreted as an integer value ‘1’ or a character value ‘1’, they are not the same thing really. I’ve never really understood this until now. Thank you! I have learned something today, now I can get some ZZZzzzzzzzzz, lol The ‘.’ notation represents the character value whereas the ‘[]’ represents the integer value. I could be wrong but I think I got it. I am assuming ‘string’ is synonymous with ‘character’ as ‘array’ is with ‘integer indices’…man Jon this is why I would not want to be a teacher as there are so many different methods of learning rather than the Pink Floyd brick in the wall british method adopted world-wide.

  6. Methods are another type of property subroutine that modifies or manipulates it in a unique way it was programmed to perform.

  7. Objects express bracket grouped elements of an array to a Boolean.

  8. It is another layer of complexity in analysis of an array. It is a comparison of properties.

  9. objects are defined as a formula. The object equates to the expression of array properties.

  10. Objects may result in the same value expressed however they bare a unique identity.


  1. String variables are a closed system. You can slice and dice them but your cannot remove pieces or add to the whole for they are immutable.

  2. do not understand at all

  3. with pleasure

  4. To serialize is to convert into a flat description. I don’t really get it but guess that it is a concatenation of arrays???

  5. JSON stands for Java Script Object Notation. I have seen this before. It is a protocol for writing arrays and objects…that’s what is reads but I do not understand.

  6. over my head

1 Like
  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?

The problem introduced in this chapter is the storage multiple values in a data structure that cannot be solved with strings or integers

  1. What variable type can be used in order to solve the problem of strong multiple values?

Arrays are a variable type that can be used to store multiple values

  1. What are properties in Javascript?

Properties are characteristic of an object

  1. Which values do no have properties

The values null and undefined do no have properties

  1. How do we access properties in a value (two ways) ?

To access properties we use the dot . or square brackets []

  1. What are methods?

Methods are functions part of the properties of an object

  1. What are objects?

Objects are an arbitrary collections of properties of a value

  1. 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 mutable and have new editable properties which is in contrast with other value types. It allows for a single object to have different content at different time

  1. How do you define an object?

We declare the object and use braces for the expression, filling it with properties separated by commas

  1. What can you say about the mutability of Javascript objects

Primitive values are immutable and arrays and objects are mutable

SECOND PART:

  1. Why can’t you add new properties to a strong variable

String variable are primitive values and so are immutable and can’t be given new properties

  1. What are rest parameters?

It is a syntax that allows a function to have any number of arguments

  1. What is serialisation and what is a use case of serialisation of data?

Serialisation is the storage of data structure into a file for transfer over networks

  1. What is JSON?

JSON is a serialisation format use in Javascript

  1. What are the differences between JSON and the way programmers write objects in plan Javascript?

All property names need to have double quotes and have simple data expressions, no function calls, bindings, or anything that involves computation

1 Like

1st Part

  1. the single variable types can only maintain single problems. This is a multi-variate problem that single variable types are unable to solve on their own.
  2. Arrays
  3. They are what some values are made of. Some expressions want to get the ‘properties’ of some values and you do that by for example typing “value.x” and get the property of x.
  4. “null” and “undefined”
  5. value.x and value[ x ]
  6. Universal JavaScript properties that contain functions. For example; “.toUpperCase” that makes all letters in caps by accessing the value given to it before the dot.
  7. Objects are values that are collections of properties.
  8. Other value types have one specific function while objects can perform a lot of tasks
  9. You use braces to create objects, and then it is defined within the braces. Separated by commas if there are multiple entities.
  10. Compared to other value types the object values are modifiable. Their properties are able to be manipulated meaning one value can have a different task later on in the control flow, unlike regular values that are immutable.

2nd Part

  1. A string is a simpler thing compared to objects, because of their immutability
  2. They let you insert an infinite number of arguments through an array.
  3. Objects are part of the computer’s memory because the arrays for example consists of the computer’s binary number of the location of the array. Because they are connected to the memory they are more difficult to distribute and therefore you can “serialize” it.
  4. JavaScript Object Notation, has a serializing function that is used for data storage and communication.
  5. Property names must be surrounded by double quotes, simple data expressions are only allowed, you can’t call functions, you can’t call bindings etc. and you are not allowed to make comments.
1 Like
Part I
  1. 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.

  1. 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.

  1. 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.

  1. Which values do not have properties?

In JavaScript only “null” and “undefined” doesn´t have properties.

  1. 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”]

  1. What are methods?

Methods are object properties that contain a function definition.
Ex.: objectName.method()

  1. 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.”

  1. 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.

  1. 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 }

  1. 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
  1. 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.

  1. 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; }

  1. 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.

  1. 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.

  1. 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.

1 Like

1.This chapter introduces ways where you can store multiple values in a data structure that cant be done in strings and integers.

  1. Arrays can help with multiple values.

  2. properties in JS can be values, functions and other objects.

4.null and undefined

5.use the . or []

  1. Methods are properties that hold function value, like .push which adds values at the end of the array.

  2. objects are a collection of properties.

8.in objects you can structure a mix of different values that can contain boolean values.

  1. An object is multiple values collectively put together e.g
    let dogs = {age :11, weight: 20, colour.brown}

  2. The mutability can be changed or re assigned.

1.Strings are immutable and their values cannot change

2.Rest parameters are inserted into functions by doing … . They show that arguments are bound to an array and anything after
… are ignored.
4. Serialisation is converting data in memory into a flat description of way the data is. Its useful
for when you wan to transfer data to a file or other computer.
5. JSON stands for java script object notation and is used for serialisation of data, this makes it easier to transfer.
6. Property names have to have double quotes, only simple data expressions are allowed.Functions, bindings, or anything that
involves computation.

1 Like
  1. How to store data in a structured manner.
  2. Object and array.
  3. Properties define some characteristic about the values in a data structure.
  4. null and undefined
  5. To access properties in a array you use: var[x]. to access a propertie in a object you cann use var.x.
  6. A method is a function that`s been assigned to a property name in an object.
  7. Objects are datastructures that contain collections of properties.
  8. An object has both state and behavior.
  9. An object is a collection of properties.
  10. You can add, delete and chance the properties of an object.

Second Part:

  1. Because string variables are unmuteble.
  2. Its a kind of dynamic parameter that can take an array with no fixed sized.
  3. oke
  4. Serialisation is a process of converting the state of Object into flat data (bits) so that it can be
    transferred over a network.
  5. JSON stands for JavaScript Object Notation and is used for exchange javascript data with other
    applications.
  6. JSON requires all property names to be surrounded by double quotes and only simple data
    expressions are allowed meaning no comments, function calls, binds or anything that involves actual
    computation are allowed.
1 Like
  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?

An array of strings is needed to store the daily activities. But there also needs to
be a boolean expression associated with each list to indicate if the squirrel mode
is on or off. So we need an array of objects that contain those two data types as parameters.

  1. What variable type can be used in order to solve the problem of storing multiple
    values?

If we want to store multiple values of the same data type, we can use arrays. If we
want to use data structures that contain multiple data types, we can use objects.

  1. What are properties in Javascript?

Properties are named values associated with an object.

  1. Which values do not have properties?

null and undefined.

  1. How can we access properties in a value (two ways)?

We can use . or []. For example car.color or car[“color”].

  1. What are methods?

Methods are properties, that hold function as a value.

  1. What are objects?

An object is collection of values of different data types.

  1. 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)?

With objects it is possible to construct data structures that contain multiple
data types.

  1. How do you define an object?
let person = {
  firstName: "Frank",
  lastName: "Callahan",
  occupation: "actor",
  fullName: function() {
    return this.firstName + " " + this.lastname;
  }
};
  1. What can you say about the mutability of Javascript objects?

Values like numbers, strings and booleans are immutable. The actual values can’t
be changed. You can derive new values from them and then make a binding to point
to the new value. Objects are different in the sense, that it is possible to change the
values in them. Also when comparing two objects with the == operator, it returns false if
we are comparing two different objects that have exactly the same values in their properties.

  1. Why can’t you add new properties to a string variable?

String variable is not an object. It is immutable, so new properties can’t be added to it.

  1. What are rest parameters?

When function that can accept unknown number of arguments is declared, the arguments
are placed in an array. The rest parameter must be the last argument. It is prefixed With
three dots. For example

function avg(...numbers) {
  let sum = 0;

  for (let num of numbers) {
    sum += num;
  }
  return sum / numbers.length;
};
  1. What is serialisation and what is a use case of serialisation of data?

Serialisation is a process of converting structured data into a format that
can be stored or shared and it can be recovered to it’s original structure.

  1. What is JSON?

JSON (JavaScript Object Notation) is a serialisation format. Here is an example of
it’s data format:

{
  "firstName": "Erkki",
  "lastName": "Tuominoja",
  "address": {
    "street": "Helsinginkatu 1",
    "city": "Helsinki",
    "state": "Uusimaa",
    "postalCode": "00520"
  },
  "phone": [
    {
      "type": "home",
      "number": "040 5554400"
    },
    {
      "type": "office",
      "number": "050 4499932"
    }
  ]
}
  1. 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. Only simple data expressions
are allowed. There are no function definitions or computations.

1 Like

Part 1

  1. Most of the time you need more information than just a string or a number. In the current example you need the information about what Jaques did on a daily bases and also if he turned into a squarrel or not.
  2. Multiple values can be stored in an array.
  3. Properties define attributes of an value.
  4. null and undefined.
  5. By using a dot or square brackets.
  6. Methods are properties that contain functions.
  7. Objects are collections of properties.
  8. Objects allow to store multiple data types.
  9. var nameOfObject = {name1: value1, name2:value2, … }
  10. Objects are mutable. You’re able to manipulate the properties of an object.

Part 2

  1. Because strings are immutable , just like numbers and Booleans.
  2. They represent an undefined amount of arguments in a function.
  3. –
  4. Serialization means to convert the information in the computer memory, into a flat description, which can be saved and shared.
  5. JSON (JavaScript Object Notation) is a popular serialization format.
  6. In JASON all property names have to be surrounded by double quotes and only simple data expressions are allowed (no functions, bindings, etc.).
1 Like

1: He has to store multiple values

2: Arrays

3: Properties are kind of certain information about values. Examples are; .length and Math.max which respectively informs us of the length of a string and the maximum function.

4: The only two values that do not have properties are null and undefined.

5: We can use dots and square brackets. They do have different functionalities.

6: Methods are properties that contain functions of the value they belong to. So you can say sequence is a method of an array, or toUpperCase is a method of a string.

7: Objects are arbitrary collections of properties. Inside the objects you can assign different types of value.

8: Objects can be modified whereas the other types of value are immutable.

9: With the use of braces. Inside the braces you will separate the properties, using commas.

10: The properties of objects can be changed. This means that the objects value can be changed to have different content at different times.
Object 1 can be equal to Object 2
but in a given instance where Object 1 and Object 3 both had the assigned value of 10, it wouldnt mean that Object 1 == Object 3.
This is because, if you changed to object1.value = 15, then object 2 value would also be changed to 15, but the object 3 value would still be 10.

SECOND PART:

1: Because strings are immutable and therefore doesn’t allow change.

2: Rest parameters are three dots followed by the last parameter of a function. e.g. function max(…numbers)
When the function is called, the rest parameter is bound to an array, which contains all further arguments.

3: Skipped =)

4: Serialization is when a big chunk of data is converted into a flat description. This is neat if you want to save a file for later or send data to another computer.

5: JavaScript Object Notation is widely used as a data storage / communication format on the Web, also in other languages than JavaScript.

6: In JSON all property names have to be surrounded by double quotes and only simple data expressions are allowed (no function calls, binding or anything that involves actual computation). Comments aren’t allowed in JSON.

1 Like
  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?
  • In order to store and process rows or sequences of data using simple variable types such as strings or integers just would not work efficiently
  1. What variable type can be used in order to solve the problem of storing multiple values?
  • An Array type variable is perfect for storing multiple values
  1. What are properties in Javascript?
  • Properties are the definition of a value within a data structure
  1. Which values do not have properties?
  • Null / Undefined
  1. How can we access properties in a value (two ways)?
  • value.x or value[x]
  1. What are methods?
  • Functions values which are stored as object properties
  1. What are objects?
  • Groups of properties
  1. 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 be used to store multiple values more efficiently (example given in the weresquirrel analogy)
  1. How do you define an object?
  • { } create objects with the properties within separated by a comma , After each properties name follows a colon: and value
  1. What can you say about the mutability of Javascript objects?
  • It provides much needed flexibility in order to change, remove or add properties to objects

SECOND PART:

  1. Why can’t you add new properties to a string variable?
  • Due to the fact strings (not an object) are immutable
  1. What are rest parameters?
  • They are used with functions to accept any types of arguments. If you put 3 dots before the parameter that is an Array and it can have its values used as arguments
  1. (Feel free to skip the sub-chapter of Math object and Destructing)
  • Absolutely:)
  1. What is serialisation and what is a use case of serialisation of data?
  • It is the process where you can convert data stored in memory to a flat format to be stored or sent to another machine efficiently
  1. What is JSON?
  • Its a very popular serialization format used in multiple programming languages
  1. What are the differences between JSON and the way programmers write objects in plain Javascript?
  • JSON is used for the transfer of data rather than logics making it not a programming language as it cannot hold computational code
1 Like

Excellent answers sir, well documented! Please keep them like that :muscle:

Carlos Z.

1 Like