Data Structures (Arrays and Objects) - Reading Assignment

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? Because we can’t access them

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

What are properties in Javascript?
A JavaScript property is a characteristic of an object, often describing attributes associated with a data structure.

Which values do not have properties?
The exceptions are null and undefined
How can we access properties in a value (two ways)?
. od []
What are methods?
a method is actually an object reference to a function.

What are objects?
An object is a collection 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)?
You can change their properties, causing a single object value to have different content at different times.
How do you define an object?
Arrays, then, are just a kind of object specialized for storing sequences of things. If you evaluate typeof [], it produces “object”.

What can you say about the mutability of Javascript objects?

In JavaScript, only objects and arrays are mutable, not primitive values. (You can make a variable name point to a new value, but the previous value is still held in memory. … Immutables are the objects whose state cannot be changed once the object is created. Strings and Numbers are Immutable.

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

2. What are rest parameters?
These are denoted by a function’s last parameter with 3 dots before its name and are useful for functions that accept any number of arguments. When the function is called, the rest parameter is bound to an array containing all further arguments.

3. 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 want to do things like saving the data to a file or transferring it to another computer on a network.

4. What is JSON?
JavaScript Object Notation is a serialisation format widely used for data storage and communication.

5. What are the differences between JSON and the way programmers write objects in plain Javascript?
All property names need to be surrounded in double quotes and only simple data expressions are allowed. So no function calls, bindings, or anything that involves actual computation. Also, 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?

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

Arrays, because they can store a series of values, and those values can even be of different data types.

3. What are properties in Javascript?
from w3schools:
-"Properties are the values associated with a JavaScript object
- A JavaScript object is a collection of unordered properties
- Properties can usually be changed, added, and deleted, but some are read only.
- Property names are strings.

4. Which values do not have properties?
-null and undefined do not have properties.

5. How can we access properties in a value (two ways)?
- There are two ways to acces properties value.x and value[x]
- “When useing a dot, the word after the dot is the literal name of the property”
- "When using square brackets, the expression between the brackets is evaluated to get a property name.
- value.x fetches the property of value named ‘x’, value[x] tries to evaluate the expression x and uses the result, coverted to a string, as the property name.
- The dot notation can only be used if the property name has a valid binding name. If you wanted to access a property named 2 or John Doe, you must use square brackets:
value[2] or value[“John Doe”]

6. What are methods?
Properties that contain functions are generally called methods of the value they belong to, as in ‘toUpperCase is a method of a string’.
someArray.push(“someValue”) or someArray.pop() are methods for manipulating an array.

7. What are objects?
Objects are variables but can contain many values from a variety of datatypes. The values are an (unordered) list of pairs of property names and their corresponding values.
"JavaScript objects are containers for named values called properties or 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)?
"A set of daily log entries can be represented as an array. But what we are looking for is an entry that stores a list of activities AND a Boolean value that indicates whether Jacques turned into a squirrel or not.

9. How do you define an object?

'Values of the type object are arbitrary collections of properties. One way to create an object is 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. Properies whose names aren’t valid binding names or valie numbers have to be quoted.

let someObject = {
age: 35,
hairColor: “brown”
};

console.log(someObject.age);
//-> 35

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.
You can change object properties, causing a single object value to have different content at different times.

Using the const binding to an object can itself not be changed and will continue to point at the same object, the contents of that object might change.

const score = {visitors: 0, home: 0};

//This is ok
score.visitors = 1;

//This is not allowed
score = {visitors:1, home: 1};

Bonus

The elements in an array are stored as the array’s properties, using numbers as property names. Because you can’t use the dot notation with numbers and usually want to use a binding that holds the index anyways, you have to use the bracket notation to get at them.

The length property of an array tells us how many elements it has. This property name is a valid binding name, you typically write array.length because that’s easier to write than array[‘length’]

PART II

Strings and their properties

1. Why can’t you add new properties to a string variable?
"We can READ propeties like length and toUpperCase from string values. But if you try to add a new property, it doesn’t stick.
"Values of type string, number, and Boolean are immutable and cannot be changed. But these types do have built-in properties, and every
string value has a number of methods, such as slice, and indexOf, which resemble array methods of the same name.

2. What are rest parameters?
A rest parameter …lastArgument allows your functions to accept any (unknown) number of arguments it might be given.
To do this, 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. If there are other parameters before it, their values aren’t part of that array.

3. (Feel free to skip the sub-chapter on Math object and Destructuring)

4. What is serialization and what is a use case of serialization of data?
"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 tablges of memory addresses to a description that can be stored or sent. **
You COULD send over your entire computer memory along with the address of the value you’re interested in, I supposed, but that doesn’t seem like the best approach.

What we can do is SERIALIZE the data. That means it is converted into a flat description. A popular format is JSON.

5. What is JSON?
JavaScript Object Notation is a widely used data storage and communication format on the web, even in languages other than JavaScript.
JSON looks similar to JavaScript’s way of writing arrays and objects, with a few restrictions.

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, binding, or anything that involves actual computation.
Comments are not allowed in JSON.

Note: JavaScript gives us the function JSON.stringify and JSON.parse to convert data to and from this format. The first takes a JavaScript value and returns a JSON-encoded string. The second takes such a string and converts it to the value it encodes.

let string = JSON.stringify({squirrel: false, events: [“weekend”]});

console.log(string)
//->{“squirrel”:false,“events”:[“weekend”]}

console.log(JSON.parse(string).events);
//->[“weekend”]

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? - it looks for correlation between data entries. Which couldn’t be solved without combining ‘events’ or having data structures.
  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? - they are expressions to access the property of a value.
  4. Which values do not have properties? - null and undefined.
  5. How can we access properties in a value (two ways)? - using value.x or value[x] - a dot or square brackets.
  6. What are methods? - properties that contain functions.
  7. What are objects? - they are standalone entities that hold multiple values in terms of 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)? - they allow the programmer to group together values.
  9. How do you define an object? - use let/var with curly braces.
  10. What can you say about the mutability of Javascript objects? - object values can be modified.

Part 2

  1. Why can’t you add new properties to a string variable? - they aren’t objects and JS doesn’t store new properties.
  2. What are rest parameters? - allows a function to accept any number of parameters.
  3. (Feel free to skip the sub-chapter of Math object and Destructing) - ok
  4. What is serialisation and what is a use case of serialisation of data? - converts data to a flat description, removing unneeded space, breaks and comments. more efficient with sending data.
  5. What is JSON? - a popular serialisation format used in JS.
  6. What are the differences between JSON and the way programmers write objects in plain Javascript? - property names in JSON are surrounded with double quotes and no comments are allowed - and no function calls, bindings or anything that needs actual computation.
1 Like
  1. Variable types like strings and integers do not include all of the important data that is needed to solve the problem.
  2. Array.
  3. Properties in JavaScript are something like the length of a string or the maximum value of a function.
  4. Null & undefined.
  5. You can access properties in a value by using a dot and using square brackets.
  6. Methods are properties that contain functions.
  7. Objects are a collection of properties expressed within braces.
  8. With objects, one value can be the same as another object, basically the object “grasps” said value. With integers, strings, arrays, and booleans you cannot have this as those values are immutable.
  9. An object is a collection of properties, these properties can be either a string or a number.
  10. You can change a property of an object, which makes hit have two different properties at different times.

Now you’ve probably come to the sub-chapter called The lycanthrope’s log. Feel free to jump to the sub-chapter called Strings and their properties.

  1. You cannot add new properties to a string variable because that value is immutable.
  2. Rest parameters allow for a function to accept any number of arguments, rest parameters are bound to arrays containing all further arguments after a function with “… last parameter” is called.
  3. Serialization is a way to convert data into a flat description.
  4. JavaScript Object Notation, which is a serialization format.
  5. 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 also not allowed in JSON.
1 Like

First part:

  1. The problem of not being able to store multiple values of different types in variables that can only hold strings or integers.
  2. Arrays are used to solve this problem.
  3. Properties are characteristics of values. For example value.length returns me how many characters there are in a value.
  4. The values “null” and “undefined” have no properties.
  5. The two most common methods of accessing properties use dot and square brackets. value.x retrieves the “x” property of value. value[x] attempts to evaluate the expression “x” and uses the result as the property name
  6. Properties that contain functions. E.g. sequence.push(4) . “.push” is a method.
  7. Objects are arbitrary collections of properties.
  8. Objects can store multiple data types.
  9. let obj= {
    squirrel: false,
    events: [“work”, “touched tree”, “pizza”,“running”]
    };
  10. Unlike numbers, strings and Booleans, which are immutable values, objects can be moddified.
    Second part:
  11. A string is not an object but a primitive type, so they are immutable.
  12. It is the use of any number of arguments in a function.
  13. I didn’t skip it, I wanted to say ahah.
  14. Serialisation is a process of converting the state of Object into flat data (bits) so that it can be
    transferred over a network.
  15. JSON stands for JavaScript Object Notation and is popular serialization format.
  16. JSON has a few restrictions. All property names must be surounded in quotes. No functions, bindings, or enything that involves actual computation. Comments are also not alowed.
1 Like

Part One -

  1. This chapter introduces problems that cannot be solved with variable types such as strings an integers as it is an investigation into which data groups or variables are grouped together a dhow they are related to each other.
  2. An Array can be used to store multiple values.
  3. In Javascript properties are an expression that returns some value of a variable or object.
  4. Null and Undefined have no properties in javascript.
  5. The two main ways to access properties in javascript are with a dot and with square brackets - eg value.x or value[x]
  6. JavaScript methods are actions that can be performed on objects. A JavaScript method is a property containing a function definition. Methods are functions stored as object properties.
  7. Objects are arbitrary collections of properties.
  8. Objects can be uniquely identified and can contain values of different types.
  9. You define an object 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. Javascript objects are all mutable, you can change an objects properties and it can have different content at different times.

Second Part -

  1. string variables are not objects and therefore you cannot add new properties ot them.
  2. Rest parameters create an array out of the last arguments supplied to a function, and can allow any number of arguments to be added. rest parameters are denoted with three full stops.
  3. ok
  4. Serialization of data is when the data is converted into a flat description. When saving or sending data as a file it is possible to serialize it, this means you can send your data as a file without it being active computational code.
  5. JSON is JavaScript Object Notation, a widely used file format for datasets.
  6. 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 computation. No comments are allowed in JSON.
1 Like
  1. storing multiple values which belong logically together in one datastructure.

  2. arrays

  3. properties belong to values and can be accessed

  4. basic datatypes such as Number or boolean

  5. with square brackets with the expression inside which resolves to the property name after the value name or through a dot after the value name followed by the name of that property

  6. methods are properties that contain functions.

  7. objects are arbitrary collections of properties.

  8. objects make it possible to store arbitary key value pairs inside of one datastructure.

  9. see 7

  10. js objects are very mutable. Another value for a property can be assigned at any time or a property can even be deleted completely.

  11. strings are immutable which means you cannot change values of this type

  12. rest parameters are there if you don’t want to specify the amount of arguments of some function

  13. a serialisation is a record of the data in the memory (ram) that represents one object. This record is than stored to hard drive.

  14. JSON is short for Java Script Object Notation, which is a serialization standard that’s widely used (not only inside java script).

  15. inside a JSON there can’t be any of these:

  • property names being without double quotes
  • function calls
  • bindings
  • comments
1 Like

Part One

  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 this sub-chapter, a complex data object is required to organize and access multiple data types tied together with one common theme, similar to a real-world filing cabinet containing labeled folders, which contain pieces of paper, which contain paragraphs, which contain sentences, which contain words, which contain letters. Where strings and integers are the basic information in a relatively unorganized format, objects are the filing cabinet which allows that data to be easily categorized and located.

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

Arrays are a variable type that can store multiple values in a list format, accessible through indexing.

  1. What are properties in Javascript?

Properties describe the data values in variables and arrays, such as data type, value or index within an array or array length.

  1. Which values do not have properties?

Null and undefined have no properties, as indicated by their names.

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

With a dot or with square brackets (value.x or value[x]).

  1. What are methods?

Properties that act as functions on the value they belong to (i.e. - value.toUpperCase)

  1. What are objects?

Complex data structures made up of various components that assist in storing multiple data types in an organized fashion.

  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 allow us to store and access multiple data types in categories relative to one another.

  1. How do you define an object?

An object is defined by name = {item1, item2, item3[x, y, z], item4}

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

Values contained with Javascript objects are mutable (changeable), whereas the value or a string or constant is immutable (unchangeable).

1 Like
  1. If you write a string of “1 2 3 4 5 6”. You run into a problem where you have trouble accessing the individual values within the string. So to solve this, they use arrays [1,2,3,4,5,6]. Which allow for the individual integers to be selected later on.

  2. The value type is Arrays

  3. A *property is a characteristic of an object, often describing attributes associated with a data structure.

4)“The exceptions are null and undefined.”

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

6)“Properties that contain functions are generally called methods”

  1. An object is a collection of properties, and a property is an association between a name and a value
    8)Objects allow for more properties to be combined. As opposed to array which only do numbers and strings. Objects allow for boolean and lists.

  2. An object is a collection of properties.

  3. “Numbers, strings, and booleans, are all immutable. Objects work differently. You can change their properties, causing a single object value to have different content at different times”

Second Part

  1. “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. “The rest parameter is bound to an array containing all further arguments.” If the array was [1,2,3] math.max would be the rest parameter that accounts for all the variables within the array.

  3. In computing, serialization is the process of translating a data structure or object state into a format that can be stored or transmitted and reconstructed later. “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. You could send over your entire
    computer memory along with the address of the value you’re interested in, I
    suppose, but that doesn’t seem like the best approach.
    What we can do is serialize the data. That means it is converted into a
    flat description. A popular serialization format is called JSON”

  4. JavaScript Object Notation. It is widely used as a
    data storage and communication format on the Web, even in languages other
    than JavaScript. JSON looks similar to JavaScript’s way of writing arrays and objects, with a
    few restrictions

  5. All names in JSON must be wrapped in double quotes. If you create an object using JSON format, javascript engine treats it the same as you would have created the object using the object literal. Safe to say that all JSON data are valid Javascript objects.

1 Like
  1. Why can’t you add new properties to a string variable?
    A string variable is immutable. It can be manipulated to create results in new string/substring variables, but the string itself cannot be altered. Strings have limited, built in functions/methods that can operate on strings.

  2. What are rest parameters?
    A rest parameter allows us to handle an indefinite number of variable inputs/input types as function arguments/parameters. Rest parameter syntax allows us to represent that indefinite number of arguments as an array.

  3. What is serialisation and what is a use case of serialisation of data?
    The process of translating an object or data structure into a transferrable format so it can be sent over a network or stored (i.e. - in an array buffer or file format). Objects, arrays, strings, numbers, true, false and null are supported formats and can be serialized and restored.

  4. What is JSON?
    JSON (Javascript Object Notation) is a subset of Javascript syntax that serializes complex data structures for transfer over networks or for storage, and can be used for objects, arrays, strings, finite numbers, true, false and null.

  5. What are the differences between JSON and the way programmers write objects in plain Javascript?
    JSON cannot translate/transcribe computations or comments and some specific characters or functions and dates. JSON objects are surrounded by curly braces {} and they are written in “key/value” pairs. Keys have to be strings and values have to be a valid JSON data type - a string, number, object, array, boolean or null.

1 Like
  1. With variables and integers we are not able to store multiple values.
  2. Arrays.
  3. Most Javascript values have properties. These define some characteristic about the values in a data structure, such as the length of an array or the index of a value.
  4. Null and undefined.
  5. Dot notation: array.length / Square brackets: array[length]
  6. Methods are properties that hold function values.
  7. Objects are data structures that can contain several properties.
    8.Objects are special as they are able to hold as many different datatypes as we need.
  8. Objects are defined as variables. can be const/var and curly braces.
  9. We can overwrite objects.

PART 2

  1. They are immutable.
  2. 3 dots before its name and are useful for functions that accept any number of arguments. When the function is called, the rest parameter is bound to an array containing all further arguments.
  3. Converting data stored in memory into a flat description of what that data is.
  4. JavaScript Object Notation is a standard used in data storage and communication on the web.
    6.Only simple expressions are allowed in JSON. There are no functions, bindings, comments, or computations.
1 Like
  1. Jacques needs a variable that can store multiple types of data. A string or integer can only store one piece of data.

  2. Arrays

  3. Properties are expressions that access a property of a value.

  4. Null and undefined.

  5. With a dot value.x
    With square brackets value[x]

  6. Methods are properties that hold a function for a value.

  7. Objects are arbitrary collections of properties.

  8. Objects can store as many values of datatypes as we want.

  9. Objects is created by using braces. Inside the braces the list of properties are separated with commas.

  10. Properties inside an object can be changed.

Second Part:

  1. Strings are immutable.

  2. It allows a function to accept any number of arguments as an array.

  3. ok

  4. When you serialize the date you convert it into a flat description. It is useful for data storage and as a communication format on the Web.

  5. JSON is a serialization format. It stands for JavaScript Object Notation.

  6. In JSON all property names have to be surrounded by double quotes and only simple data expressions are allowed.

1 Like

Part 1

  1. A variable type is needed to store multiple values and having accessibility.
  2. Array
  3. Properties are values defined inside an object
  4. Null and undefined
  5. array_name.property_name or array_name[property_name]
  6. Methods are properties that hold function values. These type of functions work only on the value that they belong to.
  7. Objects are groupings of data. They can hold different collection of properties.
  8. Objects fulfil the need to store different datatypes.
  9. Object_name{property1:“string”, property2:number};
  10. Mutability allows previously assigned the value to be changed. Objects are mutable. Strings, number and booleans are immutable.

Part 2

  1. String values types are immutable and hence can not be changed
  2. Rest parameters are inside the functions parenthesis. It represents the argument.
  3. NA
  4. Serialization converts objects and arrays into flat description in other to send or save.
  5. JSON is JavaScript Object Notation. It is a popular type of serialization.
  6. JSON is a text only format to communicate between server and client. where as Javascript is a programming language interpreted by browsers.
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? A variable type that can hold multiple values

  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 values associated with an object

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

  5. How can we access properties in a value (two ways)? With a dot or brackets after the array eg .propertyName or [propertyName]

  6. What are methods? Methods are properties that hold a function for a value

  7. What are objects? Variables that are a collection 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)? The values of an object can change, meaning a single objects value can be different at different times

  9. How do you define an object? Let object = {name: value, name2:value2}

  10. What can you say about the mutability of Javascript objects? The values of objects can be changed unlike other datatypes such as strings or numbers

  11. Why can’t you add new properties to a string variable? Since values of type string, number and Boolean are not objects, new properties will not be stored

  12. What are rest parameters? Rest parameters represent an array of all arguments to be included

  13. What is serialisation and what is a use case of serialisation of data? Serialisation converts data into a flat description of itself, in order to convert data between data types

  14. What is JSON? JavaScript Object Notation is a notation for data storage and communication

  15. What are the differences between JSON and the way programmers write objects in plain Javascript? JSON requires double quotes for all property names and not single quotes

1 Like

Part 1:

  1. The problem is not being able to store multiple values in a variable type and having a data structure.
  2. Array
  3. Properties are the values of an object.
  4. Null and undefined.
  5. Dot or square brackets i.e. nameOfArray.property or nameOfArray[property]
  6. Actions that can be performed on objects. It is expressed as a property containing a function definition.
  7. Objects are containers for named values like properties or methods.
  8. An arbitrary collection of properties.
  9. With braces { }
  10. Properties are mutable i.e. it can be changed.

Part 2:

  1. Strings are immutable and cannot be changed.
  2. 3 dots before the functions last parameter allows all the number of arguments before it to be accepted.
  3. Serialisation means data is converted into a flat description. It can save on data memory.
  4. Javascript Object Notation.
  5. All property names are in double quotes (" ").
    Only simple data expressions are allowed i.e. 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?

He needs is a data structure to store information.

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

Array

  1. What are properties in Javascript?

length is a Property. For example string “Cheese” has the Property length value 6

Every string has a toUpperCase property. When called, it will return a copy of the string in which all letters have been converted to uppercase. There is also toLowerCase, going the other way.

  1. Which values do not have properties?

Null & not defined

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

Value.x
value[x]
When using a dot, the word after the dot is the literal name of the property. When using square brackets, the expression between the brackets is evaluated to get the property name.

  1. What are methods?

Properties that contain functions are generally called methods

  1. What are objects?

Object is a collection of properties. “Work” is an object. “Went to work” is a property. Property are seperated by commas.

let descriptions = {

work: “Went to work”,

“touched tree”: “Touched a tree”

};

  1. What problem do objects solve that cannot be solved with other values types we’ve learned so far (such as integer, string, array, boolean etc)?

Objects grasp values, but other bindings and properties might be holding onto those same values. You may think of objects as octopuses with any number of tentacles, each of which has a name tattooed on it.

  1. How do you define an object?

Curly braces { }

This means that braces have two meanings in JavaScript. At the start of a statement, they start a block of statements. In any other position, they describe an object

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

Different bindings can grasp the same object

When you compare objects with JavaScript’s == operator, it compares by identity: it will produce true only if both objects are precisely the same value.

let object1 = {value: 10};

let object2 = object1;

let object3 = {value: 10};

console.log(object1 == object2);

// → true

console.log(object1 == object3);

// → false

object1.value = 15;

console.log(object2.value);

// → 15

console.log(object3.value);

// → 10

The object1 and object2 bindings grasp the same object, which is why changing object1 also changes the value of object2. They are said to have the same identity. The binding object3 points to a different objec

Now you’ve probably come to the sub-chapter called The lycanthrope’s log. Skip this chapter if you want as it for some reason introduces a lot of math which is completely unnecessary at this point.So feel free to jump to the sub-chapter called Strings and their properties.

Think about the following questions:

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

such values are immutable and cannot be changed.

  1. What are rest parameters?

When used in a function, starting the parameters with 3 dots like:

And it accept any number of arguments.

function max(…numbers) {

let result = -Infinity;

for (let number of numbers) {

if (number > result) result = number;

}

return result;

}

console.log(max(4, 1, 9, -2));
// 9

You can use a similar three-dot notation to call a function with an array of arguments.

1

let numbers = [5, 1, 7];

2

console.log(max(…numbers));

3

// → 7

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

That means data converted into a flat description.

  1. What is JSON?

A popular serialization format called JSON (pronounced “Jason”) which stands for JavaScript Object Notation. It is widely used as a data storage

  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. Comments are not allowed in JSON.

1 Like

First Part:

  1. Strings and integers are immutable. In the sub-chapter called The weresquirrel there is a need for structure the data as object and respective values.

  2. Arrays

  3. Properties are expressions that describe a caractheristic of a value.

  4. The values Null and Undefined don’t have properties.

  5. We can access properties in JavaScript with a dot and with square brackets.

  6. Methods are properties that have functions.

  7. Objects are arbitrary collection of properties. They can be created by using braces as an expression.

  8. A list of activities can be used in a function.

  9. Objects are more like an “action” or “quality” of a property.

  10. In JavaScript, you can change the objects properties, making a single object value have a different content at different times.

Second part:

  1. String variables are immutable and cannot be changed. They are not objects where properties can be set on them.
  2. The rest parameters allow the representation of an indefinite number of arguments as an array. With the help of a rest parameter a function can be called with any number of arguments , no matter how it was defined.
  3. Done.
  4. Serialization is the process of converting the Java code Object into a Byte Stream, to transfer the Object Code from one Java Virtual machine to another and recreate it using the process of Deserialization. Serialization of data is to convert a saved data file into a flat description.
  5. JSON is popular serialization format (it stands for JavaScript Object Notation). It is used for data storage and communication format on the Web.
  6. Both are very similar. However, in JSON there is more restrictions. For example, in JSON the property names have to be surrounded by doubled quotes, and only simple data expressions are allowed. There are no function calls, bindings, or anything that involves actual computation. Comments are not allowed on 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?

Normal variables like string or integers can only hold so called ‘single values’.

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

An Array is used to store the data.

  1. What are properties in Javascript?

often, Javascript values carry properties. These properties define lengths f.x. or the index.

  1. Which values do not have properties?

null and undefined do not have properties.

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

the dot . and the square bracket []

  1. What are methods?

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

  1. What are objects?

Values of the type object are arbitrary collections of properties.
A common way to create an object is by using braces as an expression.

  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 allow you to group together data.

  1. How do you define an object?

The common way to define an object is by using braces {}

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

You can change the properties of objects in Javascript, causing a single object value to have different content at different times.

1 Like
  1. While variables allow us to store only one information, data structure is what is needed because this case we need to store more than one information.

  2. Array

  3. Properties are values inside an object

  4. Null and undefined

  5. Two main ways to access properties are with a dot and with square brackets

6.Properties that contain functions are called methods of the value they belong to. For example “toUpperCase is a menthod of a string.”

  1. Objects are arbitrary collection of properties. One way to create an object is by using braces as an expression.

  2. Objects can hold different variable types and all values are able to be changed at will.

  3. Objects are defined by curly brackets.

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


  1. Such values are immutable and cannot be changed.

  2. The rest parameter allows a function to accept an indefined number of argument as an array.

  3. Skipped.

  4. Serialisation is the process of translating a data structure or object state into a format that can be stored. A use case for serialisation would be transferring data through the wires or detecting changes in time-varying data.

  5. JSON is JavaScript Object Notation and it is used as a data storage and communication format on the web.

  6. 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 aren’t allowed on 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?
    The problem introduces that there isn’t a way for data types such as integers or string to hold multiple value and requires a form of structured data format to hold multiple values as well as multiple data type

  2. What variable type can be used in order to solve the problem of storing multiple values?
    An array which is an object can be used to hold multiple value of different data types within it.

  3. What are properties in Javascript?
    properties in JavaScript are depicted as values that are link to a JavaScript object

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

  5. How can we access properties in a value (two ways)?
    using varName.propertyName for objects or varName.[indexOfProperty] for arrays

  6. What are methods?
    Methods are functions that reside within an object

  7. What are objects?
    An object is a storage of 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 properties within to be modified as opposed to data types such as string or numbers. Depending on the setup, the properties of an object are able to be configured.

  9. How do you define an object?
    An object is a store of multiple properties that are changeable and methods that are functions that can execute instructions to the computer when called upon.

  10. What can you say about the mutability of Javascript objects?
    It is not immutable which allows data to be manipulated which is both a strength and weakness

Think about the following questions:

  1. Why can’t you add new properties to a string variable?
    Because a string is meant to be used as a data type to store text and the protocol of JavaScript does not enable string to be of different data type such as object which is responsible for storing properties and methods

  2. What are rest parameters?
    rest parameter are a way to bound an entire array with the three-dot operator(…) utilized as the command to initiate rest parameter. eg: …numbers will call for the entire array named numbers

  3. What is serialisation and what is a use case of serialisation of data?
    Serialisation converts all the messy memory references of all array and objects and changing it into a flat description, eliminating the redundant portions and converting it into a data representation format which is smaller in size, lightweight, easy to read, for API and config use case that is easily integrated with other languages

  4. What is JSON?
    JavaScript Object Notation

  5. What are the differences between JSON and the way programmers write objects in plain Javascript?
    There are certain things that are not included in JSON such as functions, comments, bindings and anything that requires actual computation as opposed to JavaScript

1 Like