Data Structures (Arrays and Objects) - Reading Assignment

Part 2

  1. Why can’t you add new properties to a string variable?
    Because string variables are not objects and they are immutable

  2. What are rest parameters?
    Rest parameters allow us to include an endless amount of values in 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?
    Serialisation converts data into a file that can be stored for later and/or easily transferred to another computer

  5. What is JSON?
    JSON - Javascript Object Notation - is a popular serialisation format

  6. What are the differences between JSON and the way programmers write objects in plain Javascript?
    Double quotes must be used for all property names and only simple data expressions are allowed (nothing that involves any computation)

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 need to hold more than a single type of data.

  2. What variable type can be used in order to solve the problem of storing multiple values?
    Arrays are a variable type that can be used to store sequences of values.

  3. What are properties in Javascript?
    Properties are the values held by a string

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

  5. How can we access properties in a value (two ways)?
    There are two main ways to access properties in JavaScript - with a dot and with square brackets.

  6. What are methods?
    Methods are ways to manipulate arrays.

  7. What are objects?
    Objects are 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)?
    Objects are versatile as they can hold many different datatypes.

  9. How do you define an object?
    Objects are defined the same as any other type of variable.

  10. What can you say about the mutability of Javascript objects?
    This makes objects easier to modify, unlike the other variable types.

SECOND PART:

  1. Why can’t you add new properties to a string variable?
    Because they are not objects

  2. What are rest parameters?
    Rest parameters allow a number to accept any number arguments.

  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?
    Serialize data = convert into flat description.

  5. What is JSON?
    JSON JavaScript Object Notation

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

in JSON all properties names must be surrounded by double quotes and no function calls can be used.

1 Like
  1. In the weresquirrel scenario, if Jacques wants to collect daily data about what happens to him, then he will need to use not just integers and strings. He will need to store a list of activities from each day, plus a boolean value that shows the outcome of whether he turned into a weresquirrel that day.

  2. To solve the problem of storing multiple values, you could use an object, which has a collection of different properties. You could also use an array for storing sequences of things.

  3. Javascript properties are the values associated with an object.

  4. The values that do not have have properties are “null” and “undefined”

  5. The way to access properties in a value are with a dot and with square brackets

  6. Methods are properties that contain functions for the value they belong to, such as “toUpperCase” for a string, and “sequence.push” for an array.

  7. Objects are arbitrary collections of properties, which can be created by using braces as an expression and having a list of properties inside the braces.

  8. Objects solve the problem of being able to store different kinds of data together.

  9. You can define an object with a variable name and with properties listed inside the curly brackets { }

  10. Unlike numbers, strings, and Booleans, which are immutable, objects can have their properties changed. So an object value could have different content at different times.

SECOND PART

  1. You can’t add new properties to a string variable because the string variable is immutable and can’t be changed. So even if you tried to set some new properties, the new properties wouldn’t be stored.

  2. Rest parameters provide a way for a function to take an infinite number of arguments, written as an array. The syntax uses “…” followed by the rest parameter as the last one in the array.

  3. (Skipped)

  4. Serialization is when data is converted into a flat description. It could be used as an efficient way to send data from one computer to another without needing send along a huge amount of computer memory.

  5. JSON (JavaScript Object Notation) is a popular serialization format used and communication format used online.

  6. JSON’s appearance is similar to JavaScripts for writing arrays and objects. The restrictions for JSON are that all property names must be surrounded by double quotes, and only simple date expressions can be included. No computation is involved in JSON, and there are also no comments.

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 need to store multiple variables within a variable.
  1. What variable type can be used in order to solve the problem of storing multiple values?
  • Arrays or objects
  1. What are properties in Javascript?
  • For example properties of a number can be that its the biggest number, but for a string it would be that its the longest string of characters
  1. Which values do not have properties?
  • Null and undefined.
  1. How can we access properties in a value (two ways)?
  • With a dot and square brackets. value.x / value[x]
  1. What are methods?
  • Easier ways to transform your code, for example Hello.toUpperCase() would give you HELLO
  1. What are objects?
  • Objects are groups of data with different values.
  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)?
  • Where you need to store different types of data.
  1. How do you define an object?
  • You may think of objects as octopuses with any number
    of tentacles, each of which has a name tattooed on it
  1. What can you say about the mutability of Javascript objects?
  • Javascript objects are not immutable. Their properties can be changed causing a single object value to have different content at different times.
1 Like

SECOND PART:

  1. Why can’t you add new properties to a string variable?
  • Because it’s not like object and its immutable and cannot be changed
  1. What are rest parameters?
  • Parameter that can hold any number of arguments. For example function max(…numbers)
  1. What is serialisation and what is a use case of serialisation of data?
  • When data is transformed into a format suitable for transferring it over the network or storage
  1. What is JSON?
  • JavaScript Object Notation, It’s a way to arrange the data, so that javascript understands it
  1. What are the differences between JSON and the way programmers write objects in plain Javascript?
  • There are only simple lines of text, no functions or calculations
1 Like

PART 1
1: strings and integers each can only hold one data type. we need to be able to hold multiple different types.
2:An array.
3:Properties are values associated with an object.
4:Null and undiffined.
5-1:by using the name of the variable, a dot and the name of the property you want. for example mystring.length.
5-2:by using the name of the variable and in square brackets put a property name or a string. for example array[“length”].
6:properties that contain functions.
7:objects are collections of propperties.
8:they are able to hold many values and values of different types.
9:just like other variables, but the values are placed inside square brackets.
10: js objects can have their values changed.
PART 2
1:they are immutable.
2: they allow functions to accept any number of arguments. this is helpfull when using an array.
3:done
4:Serialization converts data into a flat description of itself. This allows us to use JSON notation to convert data between data types, from string to the value it holds and vice versa.
5:Javascript Object Notation. It is used for data storage and communication.
6:JSON does no computing, it has no functions,bindings,etc. all property names must be surrounded by double quotes.

1 Like
  1. Daily log entries do not consist of just a number or a string - each entry needs to store a list of activities and a Boolean value that indicates whether Jacques turned into a squirrel or not. These needs to be grouped together and put into a single value and then put those grouped values into an array of log entries.

  2. Array as a storage of multiple values.

  3. Expressions that represent value of the string.

  4. Null and undefined are exceptions that don’t have properties.

  5. Can be accessed with a dot and with square brackets.

  6. Properties that contain functions of the value they belong to.

  7. Collection of properties for different value types.

  8. Ability to hold different datatypes.

  9. By creating a single value, then inside the braces separate list of properties by commas.

  10. Numbers, strings and Boolean’s are immutable - value always remain the same, unlike object properties can be modified and changed to have different content at different times.

  11. String value always remain the same as it doesn’t have the ability to store changed properties.

  12. Rest parameter is bound to an array containing all further arguments.

  13. Conversion of the data into flat description, used for data storage and communication format on the web.

  14. Serialisation format of the data.

  15. JSON looks similar to JavaScript’s way of writing arrays and objects with a few exceptions: all property names surrounded by double quotes, only simple data expressions allowed - no actual computation, no comments.

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?

to store multiple values also of different type (numbers, strings, booleans) into the same box

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

objects

  1. What are properties in Javascript?

the elements of an object which store values or have some expression. Javascript has some built in obects and we can use their properties (eg. string.length)

  1. Which values do not have properties?

null undefined

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

string.length string[“length”]

  1. What are methods?

properties which contain a function

  1. What are objects?

a box where we can store different and multiple kind of values

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

to store different data type in the same place

  1. How do you define an object?

let x = new Object();
let x = { };

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

even though two objects have the same properties they are not identical.
It is possible to change an object value (property) so that now it store a different value than in the past.

SECOND PART:

  1. Why can’t you add new properties to a string variable?
    because string numbers and booleans are immutable

  2. What are rest parameters?

allow to accept any number of argument

function f(x, …y) {
}
f(10, 20, 30, 40);
in this case 20, 30, 40 are set in one 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?

in order to send a file to another pc we need to send also a description of how the elemnts of the file are memorized and linked.
serialization makes a conversion.
an example is json format which is used to send data

  1. What is JSON?

is a serialization format

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

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?
  • Let’s say we need to describe a potato and a carrot. Each would have a bunch of parameters like weight, length, volume etc, which we need for further functions. If we used only strings and numbers, we have two options:
    – type it all in two strings called “potato” and “carrot” and then struggle to get a single parameter out of those strings;
    – use a lot of variables, like potatoWeight, potatoLength, carrotWeight and so on, which would get time-consuming if we had a lot of different vegetables.
  1. What variable type can be used in order to solve the problem of storing multiple values?
  • This is where arrays come in. We can do it like this:

let potato = [90, 100, 250];
let carrot = [70, 150, 220];

That way, we can type all properties in one expression and also access each of them easily.

However, the values in an array have to be all of the same type. What I found out by trial and error is that Javascript will accept this:
let potato = [90, “yellow”, 250];
but it will quietly make it an object without any notice. Also, I found out that typeof will always call array an object, so in order to find that out you have to construct (or google) something like this:
isArr = Object.prototype.toString.call(potato) == ‘[object Array]’
which then returns true or false.

  1. What are properties in Javascript?
  • Basically properties are, well, properties of a value like length, case, each character in each position.
  • It gets interesting with arrays. Their properties are the things we type in them. In our example, properties of the potato are 90, 100 and 250. Arrays also have other properties like length and type of the values it contains.
  1. Which values do not have properties?
  • null
  • undefined
  1. How can we access properties in a value (two ways)?
  • If we want to access a character in a string, we use expression string[2], which would give us the third character of a variable called string.
  • The same is true for arrays. potato[1] would give us 100, because the number 100 is the second property of the variable called potato.
  • For properties that have a literal name like length, we can also use dot. If we wanted to find out how many positions we have given to our potato, we can use potato.length or potato[“length”]. In this case we have to put the property name in " ", because it is a name, not a keyword.
  1. What are methods?
  • They are properties that contain functions. What they do is read a property of a value and then do something with this property.
  • A simple example is Math.max which reads all of the properties and then returns the highest number.
  • For arrays, there are methods to not only read and display, but also modify the contents. .push adds a new position at the end of the array, and .pop removes the last.
  1. What are objects?
  • It is a collection of property bindings where each binding has a name. We could also describe our potato like this:
    let potato = {mass: 90, length: 100, volume: 250};
    That way, we don’t have to remember which parameter is in which position. We can access them by using their names. potato.length will return 100.
  • If potato was an array, potato.length would return 3 as it is the number of positions. What I found out is that it doesn’t work for objects. If we delete length:100, potato.length returns undefined. Apparently, objects in general don’t have a property called length.
  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)?
  • Object properties don’t have to be all of the same type which means we can finally give our potato a colour!
    let potato = {mass: 90, length: 100, volume: 250, colour: “yellow”};
  1. How do you define an object?
  • Like above, you first give it a name and then in {} state all the properties and their bindings.
  1. What can you say about the mutability of Javascript objects?
  • Strings, numbers and booleans cannot be modified. You can change a let variable to a new value, but you cannot modify the value itself. You rather assign the old name to another value.
  • Arrays and objects can be modified. You can add, remove, replace bindings in them. The whole array or object is one value that is being modified.
  • This means that if we have two equal numbers or strings or booleans, they are actually equal. There is nothing you can do to make them different.
  • For arrays and objects, though, this is not true. They may have the same contents now, but maybe you will modify one of them later. This means that the only way to make statement object1 == object2 true is if we actually define it exactly like that.

SECOND PART:

  1. Why can’t you add new properties to a string variable?
  • Strings are immutable. If you try to add a new property, the change will not be stored. What we can do is use the built-in properties like .length, .toUpperCase, .toLowerCase etc. We can also combine strings with + operator.
  1. What are rest parameters?
  • If we need a function that takes any number of arguments, we use an expression like this:
    function y (…x){
    The … makes a binding to an array of the arguments we want to give to the function.
  • If the argument is already an array, we also have to use the … :
    let x = [3, 4, 5];
    console.log (y (…x));
  • With … we can also insert an array in array:
    console.log (y (1, 2, …x, 6, 7));
  1. What is serialisation and what is a use case of serialisation of data?
  • When we make a variable, we bind the name of that variable to some value which is stored somewhere on our computer. If we want to take it to another machine, we need to convert the binding to a description.
  1. What is JSON?
  • JavaScript Object Notation. It is a format that basically converts objects and their values to strings.
  • To convert to JSON, we use function JSON.stringify.
  • To convert back from JSON, we use JSON.parse.
  1. What are the differences between JSON and the way programmers write objects in plain Javascript?
  • If we JSON our potato, it looks like this:
    “{“mass”:90,“length”:100,“volume”:250,“colour”:“yellow”}”
    All property names are in " ".
  • As we see, it is just a string. It cannot compute, call functions or create bindings. It also doesn’t contain any comments.
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 fact that he (Jacques) has to store more than one value

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

An array

  1. What are properties in Javascript?

As an example -> myString.length, where length is the 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)?

With the dot value.x and with the square brackets value[x]

  1. What are methods?

Properties that contain functions of the value they belong to as in toUpperCase is a method of a string

  1. What are objects?

Values of the type objects are arbitrary collections of properties. Inside the braces there is a list of properties separated by commas. Each property has a name followed by a colon and a value

let descriptions = {
work: "Went to work",
touched tree: Touched a tree"
};
  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 store values of different styles

  1. How do you define an object?
let descriptions = {
work: "Went to work",
touched tree: Touched a tree"
};
  1. What can you say about the mutability of Javascript objects?

Object can be modified, numbers, strings and booleans are immutable

SECOND PART:

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

They won’t “stick”, such values are immutable

  1. What are rest parameters?

Rest parameters are used to create functions that accept any number of arguments .

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

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

The process whereby an object or data structure is translated into a format suitable for transferral over a network, or storage (e.g. in an array buffer or file format). In JavaScript , for example, you can serialize an object to a JSON string by calling the function JSON. stringify()

  1. What is JSON?

Javascript Object Notation, standard used in data storage and communication on the web

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

In JSON you cannot use things like functions only simple expressions

1 Like

Hi @MarcisB, Loved your enthusiasm and diving deep into the details of the language’s functioning.
However, there’s one misunderstanding that I would like to clear out.

In the below statement –

This is not true. Javascript doesn’t “make” Array into an object. Javascript actually considers everything as an Object (Including functions :open_mouth: )! Except for these 6 primitives –

  • undefined : typeof instance === "undefined"
  • Boolean : typeof instance === "boolean"
  • Number : typeof instance === "number"
  • String : typeof instance === "string"
  • BigInt : typeof instance === "bigint"
  • Symbol : typeof instance === "symbol"

Hope this sheds a little more light on how javascript operates.
You can read through https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures for more in-depth knowledge.

Happy Learning ! :slight_smile:

2 Likes
  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?
  • Variable types such as strings and integers are only able to hold a single type of data. What we need is a data structure that is capable of storing multiple values and data types in order to keep all information organized.
  1. What variable type can be used in order to solve the problem of storing multiple values?
    -Arrays, the type capable of storing multiple values

  2. What are properties in Javascript?
    -They are expression that access a property of almost all JavaScript value

  3. Which values do not have properties?
    -null and undefined are exceptions because they do not have properties

  4. How can we access properties in a value (two ways)?
    -value.x or value[ ]

  5. What are methods?
    -Method are properties that hold function values. These are special kinds of functions that only work on the value they belong to.

  6. What are objects?
    -Objects are data structures that are capable containing an arbitary collection of properties. Using brace to contain a list key/value pairs separated by a comma.

  7. 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 special as they are able to hold as many different data types as we need.

  8. How do you define an object?
    -Objects are defined as any other variable, with the value being in a list contained within braces.

  9. What can you say about the mutability of Javascript objects?
    -Mutability of JavaScript objects means that the values they contained can be changed.

SECOND PART:

  1. Why can’t you add new properties to a string variable?
    -Strubg is not obkect but a primitive type, so they are immutable.

  2. What are rest parameters?

  • … means the rest parameters it is use to represent an array of all arguments to be included.
  1. (Feel free to skip the sub-chapter of Math object and Destructing)
  • Okay XD
  1. What is serialisation and what is a use case of serialisation of data?
    -Serialisation is converting data stored in memory into a flat description of what that data is. It is useful for when we do things like saving or transferring the data

  2. What is JSON?
    -JavaScript Object Notation, a standard used in data storage and communication on the web

  3. What are the differences between JSON and the way programmers write objects in plain Javascript?
    -Simple expression using " " are allowed in JSON. No functions, bindings, comments or computations.

1 Like
  1. Solving problems that require data structures variables types like strings and booleans can only handle single data types.
  2. Arrays are a variable type that can perform data sets
  3. It’s value in an object that describes it’s contents in a data structure or array
  4. null and undefined
  5. Can access properties in a value through Instance properties which holds data for that specific object and Static properties which holds data for all the objects.
  6. A method is a function inside the property of the object
  7. Objects are a collections of properties.
  8. Objects solve problems that require more complex data rather single value data
  9. Objects are defined as having properties and methods (state & behavior)
  10. The mutability of Javascript objects allow for their properties to be changed so a single value can have different content at different times.

SECOND PART

  1. The values in string variable are immutable and cannot be changed.
  2. Rest parameters give more options on the function parameters by making it easier to handle various inputs as parameters into the function
  3. Skipped
  4. Serialisation process of translating format in the object or data and making it transferral over network or storage. Example would be Javascript to JSON
  5. Javascript Object Notation
  6. Property names have to be in double quotes and only simple data expressions. Comments are not 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?
    Strings and integers cannot hold varying amounts of data, and cannot easily be accessed or retrieved in a way that an array can be manipulated.

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

  3. What are properties in Javascript?
    Properties are used with values to access specific extended data of that value. For example, the propert ‘max’ in the expression ‘Math.max’ to get the maximum value.

  4. Which values do not have properties?
    Null and Undefined nonvalues.

  5. How can we access properties in a value (two ways)?
    Using a ‘.’ and ‘[]’.

  6. What are methods?
    Properties that contain functions. Generally they are called methods of the values they belong to. For example, toUpperCase is a method of a string.

  7. What are objects?
    Object are values that are 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)?
    Objects can hold varying data types that other value types cannot. This allows for a more flexible value binding.

  9. How do you define an object?
    A mixed bag of values defined as a variable/object.

  10. What can you say about the mutability of Javascript objects?
    Values held in strings, numbers, and booleans cannot be changed. However, the contents of object can change.

SECOND PART:

  1. Why can’t you add new properties to a string variable?
    Because string variables are of the immutable type and cannot be changed.

  2. What are rest parameters?
    An array with any amount of arguments given. For example, function abc(…args) - args is the rest parameter while the 3 dots represent the rest of the arguments given.

  3. What is serialisation and what is a use case of serialisation of data?
    Flattening out data into a format that can be easily transported. It somewhat resembles a small database that can be called upon in code, in different languages, not just Javascript.

  4. What is JSON?
    JavaScript Object Notation - a lightweight tool the store information and and to transport that information to a web page.

  5. What are the differences between JSON and the way programmers write objects in plain Javascript?
    -no function calls
    -simple data
    -property names surrounded by quotes
    -no bindings or computations
    -comments are not allowed

1 Like

1: the problem of organizing data inside Javascript to access it later, without having to worry about losing in our code the specific item.

2: Array.

3: Expressions that allow us to access a specific property from a value. For example, the .length property of an array gives us the total amount of values inside the array

4:

null
undefined

5: by using a dot or by using square brackets

value.x
value[x]

6:properties that contains functions

7:collections of properties

8: Objects can store values and arrays inside of them. So we can build on top of them.

9:By using the ()braces where inside is a list of properties separated by commas. Each property has a name followed by a colon and a value.

10 : opposite to strings, numbers and booleans that are immutable values, objects’s properties can be modified.

PART 2

1: Strings properties are not stored by javascript as they are immutable.

2: syntax that allows us to represent an indefinite number of arguments as an array.

3:skip

4:Convert data into a flat description.

5: JavaScript Object Notation. A form of data storage and communication on the web, with different programming languages, not only javascript.

6: All property names have to be surrounded by double quotes,and only simple data expressions are allowed—no function calls, bindings, oranything that involves actual computation. Comments are not allowed

1 Like
  1. It will go through a almost realistic programming example, introducing concepts as they apply to the problem at hand, which will often build codes with functions and bindings that were introduced earlier in the text.

  2. JavaScript provides a data type specifically for storing sequences of values called an array, and is written as a list of values between square brackets, separated by commas.

  3. Properties are the values associated with a JavaScript object, which is a collection of unordered properties. Properties can usually be changed, added, and deleted, but some are read only.

  4. Undefined and null are the only two JavaScript values where you get an exception if you try to read a property.

  5. The two main ways to access properties in JavaScript are with a dot and with square brackets.

  6. They are properties that contain functions.

  7. Objects allow us to group values as well as other objects to build more complex structures or arbitrary collection of properties.

  8. Objects are able to hold or store different datatypes and sequences.

  9. Objects are defined as any other variable, with the value being a list contained within braces, which you can change their properties, causing a single object value to have different content at different times.

  10. It means that objects like numbers, strings, and Booleans, are all immutable, meaning that is impossible to change values of those types. You can combine them and derive new values from them, but when you take a specific string value, that value will always remain the same.

SECOND PART:

  1. A string is not an object but an immutable, and although the language doesn’t complain if you try to set new properties on them, but it will not store those properties.

  2. 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. It can be useful for a function to accept any number of arguments.

  3. It is a format that converts data into a flat description.

  4. JSON or JavaScript Object Notation, is widely used as a data storage and communication format on the Web, use in languages other than JavaScript.

  5. JSON looks similar to JavaScript’s way of writing arrays and objects, with a few restrictions of course. 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.

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?
Jaques needs a data structure so he can collate and analyse the data he collects.
2. What variable type can be used in order to solve the problem of storing multiple values?
Arrays are a variable type capable of storing multiple values.
3. What are properties in Javascript?
A property is a characteristic of an object. There are two types of properties; Instance properties hold data specific to an object instance. Static properties hold data that is attributed to all object instances.
4. Which values do not have properties?
Null and undefined values do not have properties.
5. How can we access properties in a value (two ways)?
The two main ways to access properties are with a “.” And “[]”. The “.” Dot property accessor syntax accesses the property name. The “[]” will try to evaluate the expression.

Example from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_accessors

const person1 = {};
person1['firstname'] = 'Mario';
person1['lastname'] = 'Rossi';

console.log(person1.firstname);
// expected output: "Mario"

const person2 = {
  firstname: 'John',
  lastname: 'Doe'
};

console.log(person2['lastname']);
// expected output: "Doe"

The dot will only work with values that look like valid binding names/ identifiers. Identifiers contain letters, $, _, and digits but must not start with digits. To access these identifiers “[]” must be used.
6. What are methods?
A method is a function that is a property of an object. They only work on the specific object they are attached to, and not to every instance of the object.
7. What are objects?
Objects are data structures that contain 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)?
Objects can hold different data types and allow correlations to be calculated.
9. How do you define an object?
An object is defined by using object-literal syntax; values are written as name:value pairs inside of curly braces.
10. What can you say about the mutability of Javascript objects?
Objects are mutable, their properties can be changed, whereas primitive data types such as strings, cannot be changed.
Part 2
1. Why can’t you add new properties to a string variable?
Strings are not objects, and while they have their own set of built in properties and the language will not complain if you try to set new properties, it will not store those properties.

2. What are rest parameters?
Rest parameters are remainder properties that are collected into an array, defined by “…”, which has to be included before the function’s last parameter, which is the name of the array.
3. (Feel free to skip the sub-chapter of Math object and Destructing)
(…next)
4. What is serialisation and what is a use case of serialisation of data?
Serialisation is a way of containing all the bindings and references made in the code. The use case is to send the code to a different terminal, locally or over the internet.
5. What is JSON?
JSON, Javascript Object Notation, is a popular serialization format. JSON is also used as a format to store and communicate data both within Javascript and by other programming languages.
6. What are the differences between JSON and the way programmers write objects in plain Javascript?
For JSON property names have to be enclosed in double quotes. Simple data expressions only, no function calls, bindings or anything that involves computation. Or comments. Javascript uses the functions JSON.stringify and JSON.parse to convert data to and from JSON.

1 Like
  1. The need to log a variety of data pieces in a single variable.
  2. An array
  3. Properties are specific characteristics
  4. Null and Undefined
  5. By using either a dot or square brackets.
  6. Functions of specific properties
  7. Set groups of properties and are contained in brackets
  8. Objects can hold all necessary data types and values.
  9. 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 : “Tesla”,
    topSpeed : 100,
    features : [“Heated Windscreen”,“Leather Seats”,“Air Conditioning”,“Sun roof”]
    };
  10. The properties of objects can be changed, therefore they are mutable (mutability of JavaScript)

2nd section

  1. String variables is not mutable, therefore new properties can not be added.
  2. It’s a way to allocate a variable number of arguments to a function.
  3. .
  4. Objects and arrays are stored in the computer’s memory, to serialize the data is to convert the information as sequences of bits holding the addresses of their contents into a flat description.
  5. JavaScript Object Notation is a popular serialization format.
  6. JSON looks similar to JavaScript with a few restrictions, all property names are inside double quotes, with only simple data expressors are allowed. No functions calls, bindings or computational. Comments are not allowed in JSON.
1 Like
  1. The chapter introduces the following problems that cannot be solved by individual strings/integers:
    a. Sometimes we want to work with more complex structures that have more than one data type.
    b. We often need to work with a series of values (array).
  2. We can use an array to store multiple values.
  3. Properties are characteristics of values eg myString.length returns the how many characters in a string.
  4. Null and undefined do not have properties and return an error.
  5. We can access properties by either usting "." or "[ ]" .
  6. Methods are properties that contain functions. eg string.toUpperCase changes a string to uppercase.
  7. Objects are groups of data, often of different types eg boolean, string etc.
  8. Objects solve the problem of creating more complex structures that have more than one data type.
  9. One way to define/create an object is by using braces with properties separated by commas. Each property has a name followed by a colon and a value.
  10. Javascript object properties can be changed, causing a single object value to have different content at different times ie they are mutable.

Second part:

  1. New properties can not be added to ordinary string, number or boolean variables as they are not objects. Such values are immutable.
  2. Rest parameters are parameters bound to an array containing all further arguments. To write such a function, you put three dots before the function’s last parameter.
    3.Skipedy do da.
  3. Serialization is used to convert data into a flat description format that can be sent over a network and easily interpreted by other computers.
  4. JSON is a popular data storage and communication notation often serialized for use on networks and the Web.
  5. The differences between JSON and objects in javascript include:
    a. No function calls, bindings, or anything that involves actual computation are allowed.
    b. Comments are not 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?

We need to store multiple values in a variable.

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

An array.

3. What are properties in Javascript?

Properties are the values associated with a JavaScript object.

4. Which values do not have properties?

null and undefined. If you try to access a property on one of these nonvalues, you get an error.

5. 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. But not necessarily the same property.

6. What are methods?

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

7. What are objects?

Values of the type object are 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)?

They can hold many values of different datatypes.

9. How do you define an object?

By using braces as an expression. 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. What can you say about the mutability of Javascript objects?

You can change their properties, causing a single object value to have different content at different times.

Part 2

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

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. What are rest parameters?

It can be useful for a function to accept any number of arguments. To write such a function, you put three dots before the function’s last parameter. When such a function is called, the rest parameter is bound to an array containing all further arguments.

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

That means it is converted into a flat description. If you want to save data in a file for later or send it to another computer over the network, you have to somehow convert these tangles of memory addresses to a description that can be stored or sent.

5. What is JSON?

Stands for JavaScript Object Notation.

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

1 Like