Data Structures (Arrays and Objects) - Reading Assignment

  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?

This sub-chapter introduces need for data structure, to group variables into into one pool which will help us work with it.

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

An array can store multiple values.

  1. What are properties in Javascript?

These are expressions that access a property of some value.

  1. Which values do not have properties?

Null and undefined.

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

By using dots or square brackets.

  1. What are methods?

Properties that contain functions.

  1. What are objects?

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

Can assign multiple variables as arrays, int, string etc. in one piece/variable.

  1. How do you define an object?

One way to create an object is by using curlybraces as an expression.

let computer = {
            desktop: true,
            insideComponents: ["motherboard", "RAM", "processor"],
            outsideComponents: ["monitor", "mouse", "keyboard", "wires"]
        };

Second way it by creating an array as a kind of object

let smartphone = [
            {specs: ["8 GB RAM", "Android", "64 GB Space"],
                used: false},
            {specs: ["6 GB", "Android", "128 GB Space", "Super AMOLED"],
                used: true},
            {specs: ["8 GB RAM", "iOS"],
                used: false},
            /* and so on... */
        ];
  1. What can you say about the mutability of Javascript objects?

It is about references. If we have two objects with the same reference in memory, changing values inside one of them will affect the values for the second, because they both reference to the same place in memory.

If we have two objects and they have different references, even they would have the same content, they would not be consider as the equal.

Second Part:

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

Values of type string, number, and Boolean are not objects, such values are
immutable and cannot be changed, it doesn’t actually store those new properties.

However these types do have built-in properties.

  1. What are rest parameters?

It enables a funtion to accept any number of arguments.

  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?

When exchanging data between a browser and a server, the data can only be text and that is why we are using serialisation. It is the process of translating data structures or object state into a format that can be stored or transmitted and reconstructed later (possibly in a different computer environment).

  1. What is JSON?

JSON is text, and we can convert any JavaScript object into JSON, and send JSON to the server.

We can also convert any JSON received from the server into JavaScript objects.

This way we can work with the data as JavaScript objects, with no complicated parsing and translations.

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

First part:

  1. Grouping up a lot of data, and structure it to find similarities and narrow down the range of data.
  2. An array
  3. Property is a part of an Object, which can be either a function or a value
  4. null and undefined
  5. value.propName, value[propName]
  6. Methods are properties that contains pointer to function
  7. Object is a collection of properties
  8. Group up some custom values and code that executes some logic related to this object
  9. let object = {value1 : value , value2: value}
  10. Objects are mutable, they can change values without changing objectId

Second part:

  1. Because it is a build in type, and it is immutable
  2. Syntax , that allows to pass different number of input arguments and work with it as with an array
  3. Okay
  4. Serialisation is a way to convert some data into representation that can be stored on a disk, or transfered through the internet and then decoded by other computer
  5. JSON is a JavaScript Object Notation. A format that is used for serialisation of JavaScript objects. To store it or communicate.
  6. In JSON only properties with a simple build in data are allowed. Names are in quotes. No functions or logic allowed there.
  1. The problems which cannot be solved with variable types such as strings or integers are storing, grouping and analyzing much and different types of data and check, where a problem could occupy.

  2. Arrays can be used to store multiple values.

  3. Properties in Javascript are values or names connected to the Object.

  4. “Null” and “undefined” are the values which don´t have properties?

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

  • value.x --> fetches the property of value named x
  • value[x]–> evaluate the expression x and use the result
  1. Methods are Properties that contain functions.

  2. Objects are arbitrary collections of properties and values.

  3. 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´s possible to store one or more different data types in one Object.

  4. How do you define an object?

  • By using braces as an expression: letDay={expr1, expres2,…}
  • letDay=[{event1:[“bla”,“bla”,“bla”]…}{event2[“bla”,“blub”]…}];
  1. What can you say about the mutability of Javascript objects?
    Other than numbers, strings and Booleans, objects are mutable and can be changed.

SECOND PART:

  1. You can’t add new properties to a string variable, because such values are immutable and therefore not changeable.

  2. Rest parameters are 3 dots that represent an arbitrary number of parameters as the function input.

  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?
    Converting the data set into a flat description, which is more easy to read and to send to another computer.

  5. What is JSON?
    JSON(JavaScript Object Notation) is a popular serialization format to store data and web-wide communication format.

  6. What are the differences between JSON and the way programmers write objects in plain Javascript?
    JSON and JavaScript are similar in writing arrays and objects with a few restrictions:

  • All property names have to be surrounded by double quotes
  • Only simple data expressions are allowed
  • No function calls, bindings or anything that involves actual computation.
  • Comments are not allowed.

Part 1:

  1. It introduces the need to include larger data sets within each variable in order to accurately track the events causing the pseudo-lycanthropic transformations. We need to be able to hold more types of information in each variable at a time to properly track the events causing these transformations.Strings and integers are specific values that can be held one at a time in any given variable and they are immutable. Therefore, they aren’t as flexible when tracking day to day changes.

  2. Objects and arrays (which are a specific type of object.)

  3. Properties are additional information about values that can be accessed using the value.property or value[property] notation. Nearly all values have properties except for null and undefined.

  4. Null and undefined.

  5. With a dot and square brackets. E.g. value.property or value[property]

  6. Properties that contain functions.

  7. Octopuses with whatever number of tentacles that have names tattooed on them. They can also be described as an arbitrary collection of properties. They are a collection of data consisting of strings, arrays, booleans, etc, that can be held within a single binding.

  8. They can be used to track something in a regular state of change. The other value types, integer, string, and booleans, are all immutable, so while they can be used to derive new values, their value cannot be changed or altered without changing them directly. Values within objects, however, can be changed by programs outside the object itself meaning that the value of an object may be different at any given point within the program. This allows us to use objects to track and update changing values within our code instead of reusing bindings that have fixed values to generate new values and assign those outputs their own bindings if we want to reuse them. They can also store different types of values within a single binding. (See question 1)

  9. An octopus with tattooed tentacles. (See questions 7). It’s notation is as seen below:

var objectA = {
food: [“bread”, “cheese”, “chicken”, “kale”],
colors: [“blue”, “red”, “purple”],
multiples: 1, 2, 3, 4, 5,
yay: true,
nay: false
}

  1. They are mutable. Unlike other value types, they can be changed and result in different values at different points within a given program.

Part 2:

  1. Because it is immutable and cannot be changed, unlike objects. Strings, integers, and Booleans already have preset properties and will not adopt new properties given to them. They’re real stubborn like that. If objects are octopuses then the other value types are mules.

Fun fact: “octopus” is derived from Greek and therefore is more consistently accurate in English when using the plural “octopuses” than the Latin plural construction “octopi.” While “octopi” is acceptable in modern English usage, it technically derives its plurality from a different language branch (Latin–>Romance langauges like Italian, Spanish, French) rather than the Germanic branch of language from which modern English has most heavily evolved.

In summation, learning new language rules is usually a pain in the ass, but at least programming languages can be hard-coded.

  1. A rest parameter is a signal within the parameters of a function or in the call to a function to evaluate all arguments following the three-dot notation (…).

  2. Mmmk.

  3. Serialization is the reformatting of data or code so that it can be more easily and efficiently transmitted from one computer to another. This way we can send our code to another programmer or computer without having to send the computer’s entire memory with indications of specific “addresses” identifying the code or data we are ultimately trying to transmit.

  4. JavaScript Object Notation is a popular serialization format used for data storage and data transfer.

  5. Property names must be within double-quotations (" "). Also, functions, bindings, comments, and anything that would normally be evaluated are not accepted.

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?

Jaques needs to store several different types of information in one location, as well as adding new variables each day. A string would not be able to hold word values, integer values, and Boolean values all at the same time, while being able to do anything useful with it.

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

An array is a new (to me) data structure that can hold various types of values. It can hold a sequence of strings or integers as well as empower the programmer to push or pop values in and out of it.

What are properties in Javascript?

Properties are an inherent value to a piece of inputted code. These values can be recalled if we know what type of property it has, and what we are looking for. For example math.max can be used to find the largest integer in a piece of code.

Which values do not have properties?

Null and undefined are the only two values that do not have a property.

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

The two main ways to access properties in JavaScript are with a dot and with

square brackets. Both value.x and value[x] access a property on value

What are methods?

Properties that contain functions are called methods of the value they belong to.

What are objects?

An object is a type of array that holds multiple types of values. Within the curly braces you can hold your Boolean phrase, then define your array with all your variables.

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 give the coder an ability to store multiple value types in one place as well as being able to push and pop values as well as recall specific items.

How do you define an object?

Objects are an arbitrary collection of values.

What can you say about the mutability of Javascript objects?

Once an value has been defined you cannot run another piece of code to change its properties. For example, if you set a string to “cat”, you cannot run code to change it to “rat”; it is immutable. However objects can be redefined in this way. If you have two objects with the same value (120 for example) if you change one, you change the other as well.

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

They are not objects.

What are rest parameters?

It is the 3 dot notation to add arguments to a function

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

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

Serialisation is a means of ‘detangaling’ the way information is stored in the memory, or ‘flattening out’ the information. This is particularly useful for situations like when you have an array nested into another array.

A use case of serialization would be if you have the array nested in another array, and you need to send it over to another computer. You could send over the whole memory and its addresses, but this is slow and cumbersome to the network. It would be better to serialize the information then send it.

What is JSON?

JSON is a format of serializing js code. It can be used with other languages as well and is often implemented as a data storage and communication format on the Web.

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

JSON works similarly to Javascript, however all property names must be double quoted, only simple data expressions are allowed (no function calls, bindings or anything that involves computation) and you can’t insert comments into the code.

  1. It introduces us to a problem that requires us to store multiple data under a single variable. We need a data structure in order to determine the cause of his problem.
  2. We can use arrays to make a data structure and compare what combination of data causes his turnings.
  3. Properties in javascript can show us special characteristic about some values.
  4. Null and undefined have no properties at all.
  5. They can be accessed either by a . or with an expression in the brackets [].
  6. Methods are like properties but they themself have functions that change the variable in a certain way and then display us back the property we asked for.
  7. Object are values that can contain a lot of properties
  8. Objects can hold as many data as we want, which enables us to solve the current problem.
  9. let journal [“info 1”, “info” 2]
  10. It means that the values can be easily modified.

SECOND PART:

  1. Javascript does not allow additional properties to be added or removed from a string variable.Ĺž
  2. Rest parameters accept any amount of argumens.
  3. Skipped.
  4. Serialization enables us to convert data structures into a format that can be stored in our computer and thus be send over to another computer.
  5. JSON is a standard file for data storage or communication over the internet.
  6. JSON requires double quotes and can only store simple expressions!
  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?

We need to find a way to store more variables at the same time and how we can sort through data to find solutions to the problem.

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

We can use arrays which is called with [i] and that can store multiple variables.

  1. What are properties in Javascript?

Properties are the values of a javascript object. .length gives us the property of an array or index.

  1. Which values do not have properties?

null or undefined

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

We can use .nameProperty or [property]

  1. What are methods?

Methods are functionality to proprties. For example the Math.max method.

  1. What are objects?

An object is a collection of properties, and a property is an association between a name (or key) and 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)?

You can group data together and store different kinds of values.

  1. How do you define an object?

Braces are used to create objects. Properties inside the braces are separated by commas. Each property is named, followed by a colon and a value.

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

Mutability means that the value of the objects can be changed.

SECOND PART:

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

They are immutable and we can`t add properties to a string, number and, Boolean.

  1. What are rest parameters?

Rest parameters are three dots that represent an arbitrary number of parameters as the function input. (…numbers)

  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?

Object serialization is the process of converting an object’s state to a string from which it can later be restored.

  1. What is JSON?

A JSON file is a file that stores simple data structures and objects in JavaScript Object Notation ( JSON ) format , which is a standard data interchange format . It is primarily used for transmitting data between a web application and a server. … JSON is commonly used in Ajax Web application programming.

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

JSON is basically plain text, or we can say string format representation of an object more technically. … JavaScript is an object -oriented programming language that is used for client-side scripting. JSON is a data exchange format and not a full-fledged programming language that creates and uses objects .

  1. The problem is that he needs to log everything he did during the day and simple variable represents one thing, so he needs a data structure.
  2. An Array can be used to store multiple values, it needs to be stored in - [“squirrel”].
  3. An expression that access a property of some value or values associated with an object (according google).
  4. Null and undefined.
  5. value.x and value[x]
  6. Methods are actions that can be performed on objects. A JavaScript method is a property containing a function definition. Example .push method add value to the array and .pop removes last item.
  7. Objects can be seen as collection of properties.
  8. It solves that with an object you can have a sequence of things helps us make more complex data structures.
  9. We define it as normal variable within the braces {}.
  10. You can change the properties, causing a single object value to have different content at different times.
    Second Part
  11. Because it is not an object and it doesn’t stick.
  12. Rest parameters are function containing all arguments. It can be called by typing “…number” and it passes its elements as separate arguments.
  13. Serialization is a process converting an object’s state to string which can be restored after. Use case - to store or transmit it to memory, a database or a file.
  14. JavaScript Object Notation(serialization format).
  15. All properties names have to be surrounded by double " " and only simple data expressions allowed.

Think about the following questions:

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?
-Storing multiple values and data types.
What variable type can be used in order to solve the problem of storing multiple values?
-Arrays
3.What are properties in Javascript?¨
-Property of the value. Example properties of the array are all the elements in it.
4.Which values do not have properties?
-null and undefined
5.How can we access properties in a value (two ways)?
-with square brackets or a dot
6.What are methods?
-Properties that contain functions. With methods you can manipulate strings.
7.What are objects?
-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)?
-You can store multiple properties inside an object and the values can be modified.
9.How do you define an object?
-Objects are defined like any other variable with the value being contained within braces
10.What can you say about the mutability of Javascript objects?
-Objects can be modified.

Second part

1.Why can’t you add new properties to a string variable?
-strings are immutable
2.What are rest parameters?
-Bound an array wihich contains all the further argumetns. It is denoted by three dots before the parameter.
3.What is serialisation and what is a use case of serialisation of data?
-Because properties only grasps their value and are stored in computers memory as sequences of bits holding the addresses. Serialization is converting the data into flat description to be able to send data to other computers.
4.What is JSON?
-Popular serialization format. It stands for Javascript Object Notation.
5.What are the differences between JSON and the way programmers write objects in plain Javascript?
-All property names have to be surrounded by double quotes. Simple data expressions only. Nothing that involves compution (functions, bindings etc.)

  1. We need to keep track of multiple data types and categories.
  2. Multiple values can be stored in arrays.
  3. Properties are specific characteristics of values.
  4. Both Null and Undefined do not have properties.
  5. Properties are accessed by using either a dot or square brackets.
  6. Methods are functions of specific properties.
  7. Objects are set groups of properties and are contained in braces.
  8. Objects can hold all necessary data types and values.
  9. Objects are made with properties contained within braces. The properties are separated with commas.
  10. Objects can be manipulated and modified by changing their properties.

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 need to log a variety of data pieces in a single variable.

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

What are properties in Javascript?
properties access a particular aspect of an object.
example:
myString.length specifically looks for the length of myString instead of a the value of the sting, or a different property all together.

Which values do not have properties?
null, undefined

How can we access properties in a value (two ways)?
“…with a dot and with
square brackets. Both value.x and value[x] access a property on value…”

What are methods?
“Properties that contain functions are generally called methods of the value
they belong to…”
example:
sequence.push(4) , push is a method for sequence

What are objects?
“…arbitrary collections of properties.”

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)?
Allows the storing of mulitple type of values (boolean, string and numbers) in the same variable.

How do you define an object?
let variableDefiningObject = {
booleanValue: true
stringVariables: [“firstString”, “secondString”]
}

What can you say about the mutability of Javascript objects?
Unlike strings, small portions of objects can be changed by later code.

Why can’t you add new properties to a string variable?
String values are immutable and cannot be changed by later code

What are rest parameters?
“…” used to indicated: accept any number of inputs

What is serialization and what is a use case of serialization of data?
Serialization is a method of encapsulating data, currently held in memory, so it can be transferred.

What is JSON?
JSON is a serialization format.

What are the differences between JSON and the way programmers write objects in plain Javascript?
“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.”

FIRST PART:

  1. Jacques needs to introduce multiple pieces of data which cannot be done with strings/integers
  2. Arrays
  3. Properties are expresssions that access a property of a javascript value (eg myString.length)
  4. Null and undefined
  5. With a dot, or square brackets (eg value.x or value[x])
  6. Methods are roperties that contain values. Both string and array objects contain a number of properties that hold function values.
  7. Objects are values which contain arbitrary collections of properties. Arrays are a kind of object.
  8. They enable us to combine a list of different properties, to express a single condition.
  9. Eg var car = {color: “blue”, make: “toyota”, year: “2010”}
  10. Mutability of objects means that the values they contain can be changed. This is different from strings, numbers, booleans etc which cannot be changed.

SECOND PART:

  1. A string is not an object. It is immutable.
  2. These are functions written with 3 dots before the function’s last parameter. They are useful as they can accept any number of arguments. When the function is called, the rest parameter is bound to an array containing all further arguments.
  3. This means converting data into a flat description. This can be useful for data storage and communication on the web.
  4. JavaScript Object Notation - widely used data storage and communication format on the Web.
  5. 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. Comments are not allowed in
    JSON.

Part 1

  1. Variables can only hold sigle type of data types(string, integer), so a data structure is needed for storing multiple values and datatypes in order to store all of the information organised.
  2. With an Array you can store multiple values.
  3. Most JavaScript values have properties to define some characteristic about the values in the data structure. Array properties can be for example: .length, indexOf, max.
  4. Null and Undifined have no properties.
    5.properties can be accessed either by using the dot method; array.max or the bracket method array[“max”].
  5. A method is a property that holds function for a type of value. It is a special kinds of function that only work on the value it belongs to.
  6. Objects are data structures that are capable of containing an arbitrary collection of properties.
  7. A object can hold different datatypes.
  8. let anObject = {property1: “value1”, property2:value2};
  9. JavaScript objects are not immutable. Their properties can be changed causing a single object value to have different content at different times.

Part 2

  1. JavaScript strings are immutable.
  2. Rest parameters represent an array with all arguments that will be included and are called by writing three dots before the functions name.
  3. Serialization is storing your data structures into a flatten format so i can be transferred.
  4. Java Script Object Notation is the standard for serializing objects in JavaScript.
  5. All property names need to be surrounded in double quotes and only simple data expressions are allowed. So no function calls, bindings, or comments are allowed in JSON.

PART 1…

  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?
    These variable types are better suited to storing single data items. You can use them for storing multiple data items, but you then need an extraction process to retrieve the data, which can be cumbersome.

  2. What variable type can be used in order to solve the problem of storing multiple values?
    Multiple values can be stored in variables of type Array, however it should be noted that arrays are limited to storing a single data type.

  3. What are properties in Javascript?
    Properties are a characteristic or attribute of variable or object. An example would be string.length, which returns the number of characters in a string.

  4. Which values do not have properties?
    The ‘null’ and ‘undefined’ values do not have any properties.

  5. How can we access properties in a value (two ways)?
    By appending a dot, followed by the property name, javascript returns the value associated with the literal name of the property. For instance, if str10=“Ten” then str10.length would be 3. Alternatively you can express the property as a string within square brackets as follows: strTen[“length”], which would also return 3.

  6. What are methods?
    Methods are properties that contain functions. Examples are:
    strTest = “test” --> strtest.toUpperCase returns “TEST”
    numTen = 10 --> numTen.toString returns “10”

  7. What are objects?
    Objects are values that hold an arbitrary collection of properties, which are derived from other values.

  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)?
    Unlike string or number values, which hold a single data item, or arrays, which can only hold multiples of the same data type, an Object can hold values of differing data types. These are collectively known as the object’s properties. For instance, object car could have the following properties:
    car.make = “Ford”
    car.topSpeed = 100
    car.features = [“Heated Windscreen”,“Leather Seats”,“Air Conditioning”,“Sun roof”]

  9. How do you define an object?
    To define an object use the ‘let’ keyword; followed by the object’s name; then, within
    curly brackets, define the properties using colons, (effectively creating key pairs); and
    finally ensure they are comma separated. e.g.
    let car = {
    make : “Ford”,
    topSpeed : 100,
    features : [“Heated Windscreen”,“Leather Seats”,“Air Conditioning”,“Sun roof”]
    };

  10. What can you say about the mutability of Javascript objects?
    Values, such as strings, numbers and booleans are immutable, meaning that their properties are inaccessible to other values. Object properties, on the other hand can be accessed and changed by other objects. For example…
    number1=10
    number2=number1
    number3=10
    When tested: number1=10, number2=10 and number3=10
    Now…
    number1=15
    When tested: number1=15, number2=10 and number3=10
    But, when using an object…
    object1.value=10
    object2=object1
    object3.value=10
    When tested: object1.value=10, object2.value=10 and object3.value=10
    Now…
    object1.value=15
    When tested: object1.value=15, object2.value=15 and object3.value=10
    Note that object2 has maintained a reference to object1

PART 2…

  1. Why can’t you add new properties to a string variable?
    Because, as a value, it is immutable and cannot be changed.

  2. What are rest parameters?
    A Rest parameter is a single parameter that will accept any number of arguments that is passed to it. It is defined by preceding it with three dots. i.e.
    function max(…numbers){}

  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?
    Objects and variables are stored at multiple memory locations which complicates the process of communicating that data to another machine. By serialising the data we flatten it into a series of simple data expressions.

  5. What is JSON?
    JSON stands for Javascript Object Notation and is used for web based communications and storage.

  6. What are the differences between JSON and the way programmers write objects in plain Javascript?
    Properties are always surrounded with double-quotes and anything complex, (function calls or bindings), or superfluous, (comments or code structure), is removed.

1.The information required to solve the weresquirrel in is the form of a mass of data that need to be structured in a block, variables and strings or intergers cannot store these

2.The type of variable to use to store block data is an array, these are defined in square brackets with a comma after each value eg. [2,4,”squirrel",”wolf”]

3.The properties in JavaScript are the way in which values of an array are recalled, usually with the value function

4.Value which do not have properties are null and undefined these non values will cause errors

5.The way you can access properties in a value is by value.x or value[x]

6.Methods are a way to add or modify an array value

7.Objects are a series of arbitrary values which are placed within an array, these can be words, strings, numbers or true/false statements

8.Objects can hold many attributes and at the same time and can be added to and removed

9.You can define an object by let function within{ } with a series of values in an array [ ]

10.Objects are mutable in JavaScript this means that the attributes and properties can change

1.You cannot add new properties to a string variable, because once it has been defined that is what will be returned, you can redefine but the initial value is lost

2.Rest parameters are a way in which you can set parameters that can be added to an array that can be called back, they are denoted by three dots beforehand

3.Phew!!

4.In an array, data is held in multiple areas in a computer, with certain values Serialization is a way in which this data is sequenced for use by other computers

5.JSON, JavaScript Object Notation, is the way objects are defined in JavaScript that can be sent, received used by other programmes

6.JSON is different from JavaScript in that no complex data expressions are allowed in JSON, no actions that require computation, no function calls or bindings.

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?

Correlations between data-sets

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

Objects & arrays

3. What are properties in Javascript?

Expressions that access a property of some value

4. Which values do not have properties?

Null and undefined

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

Both value.x and value[x]

6. What are methods?

Properties that hold function values

7. What are objects?

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

Object values can be modified

9. How do you define an object?

…same as #7?! An arbitrary collections of properties

10. What can you say about the mutability of Javascript objects?

Object values can be modified. The types of values discussed in earlier chapters, such as numbers, strings, and Booleans, are all immutable

SECOND PART:

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

String variables are used already once declared

2. What are rest parameters?

A function to accept any number of arguments

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

Making the program communicate and store itself on a computer in a much more efficient manor

5. What is JSON?

JavaScript Object Notation: It is widely used as a data storage and communication format on the Web, even in languages other than JavaScript.

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

  1. The problems that cannot be solved with primitive data types, such as strings or numbers, are:
    (a) how to record and store multiple sets of related data (different conditions on different days, and whether or not he changed into a squirrel); and
    (b) how to record and store this data in such a way that it can be effectively manipulated and analysed, in order to discover relationships and find out which conditions cause the transformation.

  2. Arrays can be used to store multiple related values.

  3. Most values have properties. These properties are name/value pairs which store information about a value e.g. a string has a length property which stores as its value the number of characters in the string.

  4. null  and  undefined  do not have properties.

  5. Properties in a value can be accessed using:
    (a) dot notation — with property names that are valid variable names:
                  value.propertyName e.g. array.length
    (b) square brackets — with property names that are…
      (i)  not valid variable names:
        value["Property Name"] e.g. object["First Name"]  (quotes needed)
        including numbers e.g. array[5]  (no quotes needed)
      (ii)  valid variable names, but expressed as strings:
         value["propertyName"] e.g. array["length"]
      and with…
      (iii) expressions that evaluate to property names e.g. array[array.length - 1]
          and…
      (iv) variable or parameter names that evaluate to property names
         e.g. array[index] in the following example:

       let array = [1, 2, 3, 4, 5];
       for (let index in array) {
          console.log(array[index] * 10);
       }                                        // => 10, 20, 30, 40, 50 
  1. Methods are properties whose values are functions. When a method is called, it automatically has access to the value (such as a string, an array, or an object) which it is a property of, without the value having to be explicitly passed in as an argument/parameter.
    Methods can be used to manipulate arrays e.g. .push() and .pop() to add and remove elements to/from the end of an array, respectively.

  2. Objects are values that contain properties (name/value pairs).

  3. Objects allow related data of different types (including further sub-sets of data within nested objects or arrays) to be grouped and stored together under one roof in a single value. This is also essentially true of arrays (which are, in fact, themselves a special type of object). However, arrays are indexed sequences of values (often of the same type), whereas “standard” objects have property names that can be any string, and which therefore:
    (i) do not imply any particular sequence to the object’s values; and also
    (ii) make “standard” objects better suited to recording, storing and manipulating related data of different value types.

  4. An object can be defined as follows:

    let objectName = {
       propertyName1: value,
       "Property Name 2": value,
       propertyName3: value
       // etc.
    };
  1. Unlike other values, JavaScript objects (including arrays) can be changed — specifically, their contents can be changed. Their property values can be modified, whole properties deleted, and new properties added. As a result, even if two separately defined objects have exactly the same name/value pairs, they will still have separate identities and, when compared, will evaluate as being unequal to each other.

Second Part

  1. You can’t add new properties to a string variable because string values are immutable (unlike object values).

  2. Rest parameters are used to pass an indeterminate number of arguments to a function. If a function has a rest parameter, it is always the function’s last (or only) parameter and is prefixed by three dots ...restParameter . The function call’s initial arguments are first matched and passed to any corresponding, specifically-defined parameters. All remaining arguments are then passed to the rest parameter, which in effect becomes an array variable with the arguments’ values as its elements. These values (however many were passed to the rest function) can then be accessed separately within the function via the rest parameter’s name followed by their corresponding array indeces in square brackets (i.e. in the standard way any array element is accessed).

  3. (Not a question)

  4. In reality, data structures such as objects and arrays only actually contain the addresses of where their data values (held by their properties) are located in the computer’s memory. Serialisation is when these data structures together with their referenced data are written in a file as descriptive text, for storage or transfer to another computer.

  5. JSON stands for JavaScript Object Notation and is a format commonly used to serialise data structures.

  6. The way objects are written in JSON and plain JavaScript is largely the same, except that in JSON:
    (i)  all property names must be written within double quotes;
    (ii) double quotes must be used for all string values (i.e. no option to use single quotes);
    (iii) no functions/methods are allowed; and
    (iv) no comments are allowed.

  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 can not store multiple values so to write a data structure to store information would be very time-consuming.

  2. What variable type can be used in order to solve the problem of storing multiple values?
    An array is a data type specifically for storing sequences of values, provided by Javascript.

  3. What are properties in Javascript?
    Properties are characteristics that the values have, like length, max, min, etc.

  4. Which values do not have properties?
    Only “null” and “undefined” do not have any properties.

  5. How can we access properties in a value (two ways)?
    The two ways are value.x and value[x] (for the value example), the latter being more for numbers. The first way is for binding names, like color, length, etc.

  6. What are methods?
    Methods are properties that contain functions, like toUpperCase.

  7. What are objects?
    An object is an arbitrary collection of values (properties and methods).

  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)?
    Objects allow us to store multiple data types in a single value (object).

  9. How do you define an object?
    We define an object with braces and inside there are properties followed by a colon and a value. Properties are separated by commas.

  10. What can you say about the mutability of Javascript objects?
    The properties of objects can be changed, meaning they are mutable (mutability of Javascript).

SECOND PART:

  1. Why can’t you add new properties to a string variable?
    A string variable is not mutable (like an object) and so it is not possible to add new properties.

  2. What are rest parameters?
    Rest parameters allow us to represent an indefinite number of arguments as an array.

  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?
    Serialization is converting data into “flat description”, meaning we can have it in a format that can be sent to another computer. For example to access the “memory” of an array inside another array, from a different computer.

  5. What is JSON?
    JSON means Javascript Object Notation and is a serialization format, widely used as a data storage and communication format on the web.

  6. 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. This means no functions, bindings or anything that involves actual computation. No comments as well.

My understanding is that you can store a mix of data types in the same array. I agree that it isn’t very common, but it certainly seems possible. For example, take a look at W3Schools JavaScript Arrays: the first example in the section Arrays are Objects (about a third of the way down the page) uses an array that contains both string and number types. On the same page, the next section Array Elements Can Be Objects also suggests that the same array can contain variables referencing a mix of different object types, such as functions and other arrays.

This question confused me at first, because, after all, arrays are a special type of object and, as I’ve mentioned above, can also technically contain a mix of data types. If we aren’t comparing objects with arrays, but only with the other value types, then I agree with your answer. As arrays also seem to be mostly used to store multiple values of the same type, then I would also say that one of the main reasons for using “standard” objects, with string-type property names, is because…

However, if, as the question seems to implicate, we are also comparing “standard” objects with arrays — as well as with the other value types — what do you think about the following as a possible additional solution provided by “standard” objects (and in contrast to arrays)?

@filip, do you also have any comments about this?