Data Structures (Arrays and Objects) - Reading Assignment

First part

  1. In the introduced wiresquirrel scenario, a protagonist named Jacques every now and then transforms into a squirrel. To find out what triggers this change, he decides to keep a daily log of everything he does on day and whether the transformation happened. For this task he needs a certain data structure to store this information; simple built-in types like booleans, numbers and strings are not sufficient (though it is theoretically possible to store large amounts of data in a single large string, it would be extremely complex to access/modify certain parts), he rather needs a way to represent sequences of values as well as a way of grouping different values into a single value.
  2. To solve the problem of storing multiple values we can use arrays and in a more general way the Object type in JavaScript (in fact, arrays are just special types of objects).
  3. Properties are special values attached to objects, accessible via a certain key. Almost all values in JavaScript contain properties, except…
  4. … null and undefined.
  5. Properties can be accessed either with a dot or with square brackets:
    someObject.myProperty vs. someObject["myProperty"]
    In the first notation, the dot follows a literal name of the property, while on the bracket notation, the expression between the brackets is first evaluated to get the property name.
  6. Methods are properties that hold function values.
  7. Objects are arbitrary collections of properites.
  8. Objects allow us to group several values into a single value (see also question 1).
  9. An object is defined with an expression of curly brackets ({ ... }) where inside the brackets is a comma-separated list of properties. Each property consists of a name, followed by a colon and a value. Example for an object describing a person:
let myself = {
  age : 30,
  sex : "male",
  nickname : "theStack",
};
  1. In contast to simple built-in types as numbers, booleans and strings, objects are mutable, i.e. their properties can have different values at different times.

Second part coming soon…

  1. he needs a data structure to keep track of several values

  2. arrays

  3. Almost all values in javascript have properties except “null” and “undefined”. Properties are some kind of features of these values for expample the length of a string.

  4. “null” , “undefined”

  5. dot: value.x or square brackets : value[x]

  6. properties that contain functions

  7. data structures that represent a certain amount of properties

  8. storing multiple data types

  9. var objectName = {features of the object}

  10. mutability is the ability to change properties. Objects are mutable whereas booleans or strings are immutable

  11. because string variables are immutable

  12. rest paramters are arrays which contain all arguments of a function which have not been covered by the first parameters. e.g.: function myFunc(num1, num2, …nums) { … } you can call myFunc with as many arguments as you want. the first two arguments are stored in num1, num2 and every further argument is sotred in the array called nums.

  13. serealization means converting data into a flat description which makes it convenient to save data to a file.

  14. JSON (JavaScript Object Notation) is a popular serialization format.

  15. JSON has some restrictions:

  1. no function calls
  2. no bindings
  3. no comments
  4. properties have to be in double quotes
  5. only simple data expressions
1 Like

Second part

  1. Strings are immutable, hence you can’t add new properties.
  2. With rest parameters an arbitrary number of parameters can be passed and evaluated in a function. They can only be used as last parameter by putting three dots in front of the name and are bound to an array.
  3. –
  4. Serialization describes the process of converting data in the computer memory into a flat description, which could be a single large string. Examples of common serialisation formats are XML and JSON. A use case for data serialization is for example save the state of a program in a file to be loaded at a later point in time (e.g. the save/load funcitonality in a computer game).
  5. JSON is an acronym for JavaScript Object Notation and is a popular data serialization format, used as a data storage and communication format on the Web.
  6. In JSON, all properties have to be surrounded by double quotes and there are only simple values allowed which don’t involve any computation. Also, there are also no comments allowed in the JSON format.

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 to solve is that we need some kind of variable that let us hold the value of different types of data.

What variable type can be used in order to solve the problem of storing multiple values?
we can use tha Arrays. they can store multiple values.

What are properties in Javascript?
Javascript has properties for most of the values. So you can have values in which you can use a lot of properties already built in in javaScript or you can add some properties to your values .

Which values do not have properties?
null and undefined are values that have no properties.

How can we access properties in a value (two ways)?
for example if we have ‘ourValue’ , the two options we have to access the properties in ourValue are with the dot notation like ourValue.property or with the brackets like ourValue[propertry] .

What are methods?
Methods are properties that hold a function.

What are objects?
Objects are a collection of different kind of data types that contains key:value pairs and has the ability to store big amount of data.

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 objects solved the problem of have a big amount of organized data under the same object .

How do you define an object?
you define an object with the curly brackets. like let myObject = {x:1 ,y:2 ,z:3 }; where inside the curly brackets we store our values separated by comas.

What can you say about the mutability of Javascript objects?
The objects are mutable , example you can have the same object with different values and content in different moments of time.

Second part in the next text

What problems does this chapter introduce that cannot be solved with variable types such as strings or integers?
- We need to have dynamic variables and the ability to change the information inside the variable.
What variable type can be used in order to solve the problem of storing multiple values?
- We can use the array variable.
What are properties in Javascript?
- The different elements within a variable are its properties, for example the length of an array is a property of the array
Which values do not have properties?
- null and undefined do not have properties.
How can we access properties in a value (two ways)?
- We can access a property by typing .‘property we want’ at the end of the variable or the property we want followed by square brackets with the variable we want the property from.
What are methods?
- Methods are built in functions that we can use to modify properties.
What are objects?
-Objects are variables that can contain more than one value.
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 many different variables within on named variable, and modify those variables whenever we want to. The other ones we have learned so far are “immutable” and cannot be changed without changing them in the rest of the program
How do you define an object?
- An object is defined by putting square brackets around the variables.
What can you say about the mutability of Javascript objects?
- Mutability of objects means that the variables within are dynamic and can be modified by the program.

Why can’t you add new properties to a string variable?
- A string variable is immutable and will always have the same value.
What are rest parameters?
- rest parameters allow us to call any number of arguments from input data, they all us to not specify an exact amount of data to be called for.
What is serialisation and what is a use case of serialisation of data?
- Serialization is converting data into a flat description. It converts the data so that it is more efficient than sending over the complete memory
What is JSON?
-JSON is JavaScript Object Notation, It is a form of serialization and allows for faster communication among different programs
What are the differences between JSON and the way programmers write objects in plain Javascript?
-JSON uses “double quotes” only and JavaScript doesn’t care which you use as long as you are consistent. JSON cannot have any function calls or anything that involves computation.

  1. The problem that occurs within weresquirrel is that we cannot easily access specific parts of strings or integers. We would have many points of data to store under one variable but cannot do that with strings or integers.

  2. Arrays

  3. Properties are “characteristics” of values in Javascript.

  4. null and undefined

  5. You can access properties by string after you type a “.” after the value name or you can use “[]” to use numbers or bindings.

  6. Methods are properties which contain functions

  7. An object is a collection of properties.

  8. Each value within the array can carry more values which have boolean values.

  9. One way is to use braces as an expression, inside being a list of properties. Each property has a name followed by a colon and a value.

  10. Objects can be manipulated after being created. You can change their properties unlike strings, booleans, and numbers.

  11. Because a string variable is not an object that can be given properties. Strings have a set of their own built in properties though.

  12. A rest parameter becomes an array of whatever arguments are inputted

  13. (4)Serialization is the conversion of data into a flat description. The use is good for wanting to save data in a file for later or to send to another computer.

  14. (5)JSON is Javascript Object Notation. It is a data storage and communication (serialization) format used on the web.

  15. (6)In JSON, all property names must be surrounded by double quotes and only simple expressions are allowed. No function calls, bindings, or any computation. No comments either.

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 solve this problem, Jacques needs to be able to store multiple values in a data structure. In this way he can keep track of data to determine which factors are causing the transformation to occur.

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

3. What are properties in Javascript?
Properties are characteristics of a value. For example, myString.length.

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

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

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

7. What are objects?
Values of 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)?
Objects can hold values of different datatypes.

9. How do you define an object?
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. What can you say about the mutability of Javascript objects?
Objects are mutable, meaning that you can change their properties.

SECOND PART:

1. Why can’t you add new properties to a string variable?
Values of type string, number and boolean are not objects and are immutable.

2. What are rest parameters?
The rest parameter syntax allows us to represent an indefinite number of arguments as an array. If an argument of a function is prefixed with “…” it becomes an array whose elements from 0 (inclusive) to the Args.length (exculsive) are supplied by the actual arguments passed to the function.

3. What is serialisation and what is a use case of serialisation 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 tangles of memory addresses to a description that can be stored or sent. To do this, we can “serialize” the data, which means that it is converted to a flat description.

4. What is JSON?
JSON (JavaScript Object Notation) is a popular serialization format. It is widely used as a data storage and communication format on the Web.

5. What are the differences between JSON and the way programmers write objects in plain Javascript?
JSON looks similar to JavaScript’s say 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 also not allowed in JSON.

2 Likes
  1. Problems that cannot be solved with variable types such as strings or integers can be solved with objects which can contain many values.
  2. Arrays are one variable type capable of storing multiple values.
  3. Properties in JavaScript objects are named values.
  4. A primitive data types do not have properties. (string, number, boolean, null, undefined)
  5. We can access properties with a dot and with square brackets.
  6. Properties that contain functions are generally called methods.
  7. Object are arbitrary collections of properties.
  8. Objects are special as they are able to hold as many different datatypes as we need.
  9. Objects are defined using curly braces.
  10. JavaScript objects are mutable, you can change their properties, causing a single object value to have different content at different times.

Strings and their properties:

  1. String variables are immutable and cannot be changed.
  2. Rest parameters (…) allow a function to accept any number of arguments.
  3. Serialization is the process of converting data structures or an object state into a format that can be stored or sent.
  4. JSON stands for JavaScript Object Notation. It is used as a 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, comments or anything that involves actual computation are not 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?
Not all data can be attributed to only one type. Some data have multiple values and some a mix of types and need to be saved as a collection or a set of data.
2. What variable type can be used in order to solve the problem of storing multiple values?
arrays
3. What are properties in Javascript?
The term property is used to describe attributes associated with data structure.
4. Which values do not have properties?
null and undefined
5. How can we access properties in a value (two ways)?
Using (.) or [ ]
6. What are methods?
Methods are also a values properties, but are specifically functions of that value. They are accessed with the (.)

  let myArray = [1, 2, 3];
  myArray.push(4);

7. What are objects?
Objects are an abitraty 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)?
They allow us to group a collection of different types of data into one object.
9. How do you define an object?

let house1 = {
bedrooms: 2,
occupied: false,
issues: “needs to be repaired”
};

10. What can you say about the mutability of Javascript objects?
Object values can be modified causing a single object value to have different content at different times.

1. Why can’t you add new properties to a string variable?
Because they are not objects and cannot store any properties if you try to set them. However they do have inbuilt methods such as slice and indexOf
2. What are rest parameters?
Rest parameters allow us to represent an indefinite number of arguments as an array.
3. What is serialisation and what is a use case of serialisation of data?
Serialiation is when data is presented into a format suitable for transferral over a network.
4. What is JSON?
Javascript Object Notation which is widely used as a data storage and communication format on the web.
5. What are the differences between JSON and the way programmers write objects in plain Javascript?
JSON only allows simple expressions and doesn’t allow comments. This means no functions or bindings.
Also in JSON both the key and the value are enclosed in double quotes:
“key”:”value”

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?

Jacques wants to record all his activities in a day. Since the information he is going to submit needs to be organized in a large set, an arra and object will be a better fit than a string.

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

A data type that will correspond to the storing of multiple values is an array.

3.What are properties in Javascript?

Properties in JavaScript entail a description of a value. It should be noted that values null and undefined are exceptions to calling a property of these values. To call a property of a value, it can be extracted by placing a period and property name or a square bracket after the value.

4.Which values do not have properties?

As mentioned previously, only null and undefined do not have properties.

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

A programmer can access a property of a value by either a period and property after the value or brackets after the value.

6.What are methods?

Methods are properties that contain functions.

7.What are objects?

Objects are a log entry of data arranged as an array.

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 beneficial in containing an arbitrary collection of properties.

9.How do you define an object?

Objects are defined as any other variable, with the value composing of a list contained within braces.

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

Unlike the data type of strings, objects enable for objects to be changed.

SECOND PART:

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

Strings are not an object. Rather, they are primitive type, indicating they are immutable.

2.What are rest parameters?

Rest parameters enable for a function to accept any number of arguments. Additionally, the rest parameter is bound to an array to an array containing all further arguments. To create a rest parameters, they are denoted by three dots prior to the last parameter.

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

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

Serialisation is the conversion of saved data into a flat description. This enables the flexibility for the file to transfer within a computer and network easily.

5.What is JSON?

JSON stands for the JavaScript Object Notation.

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

Similarly to arrays and objects noted in JavaScript, in JSON the properties are surrounded by double quotes but unlike in JavaScript, only simple data expression is allowed. This means no function calls, bindings, and 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?
    

relation and comparison between 2 variables.

  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?
    

properties are the name of some type of data in an array or data structure

  1. Which values do not have properties?
    

standard data types: int, str, bool, undefined, null

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

object.value
object[‘value’]

  1. What are methods?
    

methods are functions within a class. There are many pre-defined methods in a programming language that can be used for certain data types such as string.length()

  1. What are objects?
    

Objects are data structures which hold different types of data that pertain to a single variable.
They can also be referred to as classes which can perform various repeatable functions.

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

being able to hold various types of data.

  1. How do you define an object?
    

objects in js are defined by {}
properties and values populate the object
let object = {property: “value”}

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

values of properties in an object can be changed as needed
SECOND PART

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

because the data type doesn’t allow such an operation, but you could add a string to a property in an object.

  1. What are rest parameters?
    

Rest parameters allow you to pass any number of arguments / values to a function.

awesomeFunction = function(…){
// do something with all the parameters passed
}

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

this one is useful for creating random numbers which are required for some cryptos such as BTC back in the day and IOTA.

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

Serialization is a fancy word for putting all the data in one line of text (string). Deserialization takes a string and puts it into a more elegant object which can be manipulated through it’s properties and values which cannot be done when the data is serialized.

  1. What is JSON?
    

JSON is a type of data model which can be used by many computer languages to store and transfer the important data.

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

JSON is an object model which means it cannot handle comments. JSON does not care which data structures you pass to it as long as they are in the proper syntax.

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?
    We need to keep a daily log of everything a person does on a given day and the resulting form he is in. The first thing we need is a data structure to store this information in a structured manner. Afterwards we will need to be able to treat these data to perform statistical calculations.

  2. What variable type can be used in order to solve the problem of storing multiple values?
    JavaScript provides a data type specifically for storing sequences of values. It is called an array.

  3. What are properties in Javascript?
    Properties are the building blocks of objects.

  4. Which values do not have properties?
    Almost all JavaScript values have properties. The exceptions are 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. The difference is in how x is interpreted. 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.

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

     let doh = "Doh";
     console.log(typeof doh.toUpperCase);
     // → function
    
  7. What are objects?
    Values of the type object are arbitrary collections of properties.
    Example: a set of daily log entries can be represented as an array. But the 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 the binary consequence of the activities. Ideally, we would like to group these together into a single value and then put those grouped values into an array of log entries.

  8. What problem do objects solve that cannot be solved with other value types we’ve learned so far (such as integer, string, array, boolean etc)?
    We can bundle arbitrary collections of properties in a structured way.

  9. How do you define an object?
    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.

  10. What can you say about the mutability of Javascript objects?
    The types of values discussed in earlier chapters, such as numbers, strings, and Booleans, are all immutable —it 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.
    Objects work differently. 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 (as is the case of number, and Boolean are not objects, so you can’t add new properties. They are immutable and can’t 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, this 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 it is the only parameter, it will hold all arguments.

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

  4. What is serialisation and what is a use case of serialisation of data?
    Objects and arrays are stored in the computer’s memory as sequences of bits holding the
    addresses of their contents. If you want to save data in a file for later or send it to another computer over the network, you have to convert these tangles of memory addresses to a description that can be stored or sent. What we can do is serialize the data. That means it is converted into a flat description.

  5. What is JSON?
    A popular serialization format is called JSON, which stands for 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. Also comments are not allowed in JSON.


1 - The problem presents a situation where a datatype capable of storing multiple values is required. Primitive data types such as integers and strings are not capable of that.

2 - An ‘array’ allows for storing multiple values in a single binding.

3 - Properties define characteristics and traits of a value or binding.

4 - undefined and null

5 - Using the literal name of the value followed by a dot (ex: array.length) or through the use of square brackets (ex: array[“length”]

6 - Methods are basically functions associated to a value’s property.

7 - Methods are abstract data structures which contain an arbitrary collection of properties.

8 - Objects are flexible data structures as they allow the programmer to define which datatypes, values and properties it will contain.

9 - They are defined similarly to other bindings. Its structure must be contained within braces and ended with a ‘;’.

10 - Javascript allows the values contained within and object to be changed, unlike primitive datatypes which keep the values they are defined with.


1 - Primitive data types (such as strings, integers, booleans, etc), unlike objecsts, are immutable.

2 - Rest parameters allow for functions to accept any number of arguments. They are preceded by 3 dots before it’s name in a function definition.

4 - Serialisation is the conversion of data stored in memory into a simple string-like description of what thjis data is.

5 - JSON (JavaScript Object Notation) is a popular serialisation format.

6 - Notation and syntax rules. Also JSON does not allow for comments or function calls.

What problems does this chapter introduce that cannot be solved with variable types such as strings or integers?
variables hold only a single value. In many cases information requires more than one value or type of value to be stored.
What variable type can be used in order to solve the problem of storing multiple values?
Strings (not practical) and arrays
What are properties in Javascript?
Define the characteristics of a some value
Which values do not have properties?
null and undefined
How can we access properties in a value (two ways)?
with a dot (e.g. array.x) or brackets (e.g array[x] )
What are methods?
Properties that contain functions are generally called methods of the value
What are objects?
object are 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)?
Objects allow multiple properties to be defined and assigned
How do you define an object?
objectname={property1:[x1,x2,…,xn], property2:[y1,y2,…,ym]}
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.

Why can’t you add new properties to a string variable?
String values are immutable and cannot be changed.
What are rest parameters?
A function to accept any number of arguments
What is serialisation and what is a use case of serialisation of data?
If you want to save data in a file for later or send it to another computer over the network, you can convert it into a flat description.
What is JSON?
A popular serialization format is called JSON (pronounced “Jason”), which stands for JavaScript Object Notation. It is widely used as a data storage and communication format on the Web, even in languages other than JavaScript.
What are the differences between JSON and the way programmers write objects in plain Javascript?
In JSON all property names have to be surrounded by double quotes, and only simple data expressions are allowed—no function calls, bindings, or anything that involves actual computation. Comments are not allowed in
JSON.

Data structures (Arrays and Objects)

part1


  1. To many variables is messy. You can order it better in 1 variable with multiple values (properties) of 1 single type (ex. arrays)

  2. Object, for example an array.

  3. Properties are expressions that acces a property of a value. It's almost the most important part of of any Javascript Object

  4. null and undefined. null is a null value assigned to a variable. undefined is a variable without a value ⚠️

  5. objectName.propertyName
    objectName["propertyName"]

  6. Actions that can be performed ON Objects
    = property containing a Function
    var person = { firstName: "John", lastName : "Doe", fullName : function() { return this.firstName + " " + this.lastName; } };.----> fullName is a method. To acces a method = ObjectName.method(); Without round brackets , it will return the function definition. There are build in methods (ex. var inputtedText = message.toUpperCase();

  7. Objects (Very Important Part) = VIP :smiley:
    Objects are variables containing another collection of variables. a collection of named values. Like an array of properties in each value of another array (object) . In JS almost everthing can be an object, except a primitive, those are immutable, hard coded like a constant.

  8. Having a collection of named values (properties) in 1 variable. This makes it more clear and easier to work with.

  9. var person = [FirstName="John",lastName="Doe"];

  10. You can change a property of an object. make a new variable with same properties of an object. You can manipulate properties except primitives.
    They are adressed by reference, NOT by value! new person object, will not make a copy of the object, but recieve its properties. So you reference new variable of properties of the object.

Part2

  1. a String (also numbers, boolean, null and undefined) are Primitives
    a Primitive is not an object and has no methods.
    All primitives are immutable, they cannot be altered. It is important not to confuse a primitive itself with a variable assigned a primitive value. The variable may be reassigned a new value, but the existing value can not be changed in the ways that objects, arrays, and functions can be altered.

  2. ES6 brought rest parameter to ease the work of developers. For arguments objects, rest parameters are indicated by three dots … and precedes a parameter. With this, set indefinite number of arguments as an array, which are Array instances ex. function add(...numbers).

  3. Objects and arrays are stored in the computers memory. If you want to save or send data, we could convert the data into a flat description, in an organized simple notation in a file.

  4. JSON = JavaScript Object Notation, and is a way to store information in an organized, easy-to-access manner. it gives us a human-readable collection of data that we can access in a really logical manner.

  5. in JSON, we use double-quotes for all property names (instead single quotes) in JSON only simple data expressions are allowed. NO computational code (like functions,bindings,..). also comments are NOT allowed


//please correct my mistakes

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?

Storing multiple values is the problem this chapter introduces 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?

An array is the variable type, which can be used in order to solve the problem of storing multiple values.

3. What are properties in Javascript?

Properties are expressions that access a property of some value.

4. Which values do not have properties?

Null and undefined are values that do not have properties.

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

Two ways we can access properties in a value are with a dot and with
square brackets.

6. What are methods?

Methods are properties that contain functions.

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 solve the problem of not being able to group log entries into a single value.

9. How do you define an object?

  • One way to define an object is by using braces as an expression.
  • Inside the braces, there’s 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 say that objects are mutable.

PART TWO:

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

You can’t add new properties to a string variable, because objects are immutable.

2. What are rest parameters?

Rest parameters represent an indefinite number of arguments as an array.

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

Serialisation is converting data into a flat description.

A use case of serialisation of data is data storage.

5. What is JSON?

JSON (pronounced “Jason”), which stands for JavaScript Object Notation is a popular serialization format. It’s extensively used as a data storage and communication format on the Internet - in JavaScript and other languages.

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

The differences between JSON and the way programmers write objects in plain Javascript are:

  • All property names must be surrounded by double quotes.
  • Only simple data expressions are allowed - function calls, bindings, or anything that involves actual computation aren’t allowed.
  • JSON doesn’t allow comments.
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?

Storing and working with large sets of custom data.

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

Arrays

  1. What are properties in Javascript?

An association between a name and a value that is a part of an object

  1. Which values do not have properties?

Null , undefined

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

obj.property and obj[“property”]

  1. What are methods?

Functioned defined inside of an object.

  1. What are objects?
    Objects are used to store keyed collections of various data and more complex entities

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

Grouping together multiple value types

  1. How do you define an object?

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

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

Objects ARE mutable- so their properties CAN be changed.

SECOND PART:

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

A string IS NOT mutable- so their properties CAN NOT be changed.

  1. What are rest parameters?

Open ended – can 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?

Converting complex data into a flat description. Useful to store or send over the network.

  1. What is JSON?

JavaScript Object Notation, is a minimal, readable format for structuring data. It is used primarily to transmit data between a server and web application, as an alternative to XML.

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

In JSON, all property names have to be surrounded by double quotes, and only simple data expressions are allowed—no function calls, bindings, or anything that involves actual computation. Comments are not allowed in JSON.

1 Like
  1. He needs to be able to store different types of values.

  2. we use an Array

  3. Null and undefined

  4. With a dot and square brackets

  5. Properties that contain fuctions

  6. Arbitrary collections of properties

  7. They can contain groups of different properties

  8. Put inside braces

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

  10. string variables are imutable

  11. They can hold a number of arguments when called it is bound to all further arguments

  12. Convert the data to a flat description

  13. JavaScript Object Notation used for data storage on the web

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

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 real world application, we need to store a large amount of complex data which cannot be solved simply by strings or integers.

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

Arrays provides a data type that specially for store sequences of values. It is written as a list of values between square brackets, separated by commas.

3. What are properties in Javascript?
Almost all JavaScript values have properties.These are expressions that access a property of some value.

4. Which values do not have properties?
The exceptions are null and
undefined.

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.

6. What are methods?
Both value.x and value[x] access a property on value—but not necessarily the same property. The difference is in how x is interpreted. 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. Whereas value.x fetches the property of value named “x”, value[x] tries to evaluate the expression x and uses the result, converted
to a string, as the property name.

.push .pop

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

Object can store values with different properties.

9. How do you define an object?

create an object is by using braces as an expression, properties are separated by commas, each property has a name and followed by a colon and a value.

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

object values can be modified, you can change their properties, causing a single
object value to have different content at different times.

1 Like

First Part:

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 solve Jecque’s problem he needs register every day what he did along the day. Once he didn’t know in how many days the problem will be solve, variables types as strings or integers aren’t appropriate to storage the whole history information.

2. What variable type can be used in order to solve the problem of storing multiple values?
To wrap the information of one day we can use a object. Then to storage the many objects of each day we can use a array.

3. What are properties in Javascript?
Except null and undefined, all other values in JavaScript have properties, that somehow storage or calculate informations about this value.

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

5. How can we access properties in a value (two ways)?
The two way are value.property and value[property].

6. What are methods?
Method is a properties that contain a function.

7. What are objects?
Object is a collection of properties, that contain informations about the same realm.

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 group properties of different types and traffic these information easier to many places through the program.

9. How do you define an object?
By using braces and inside 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?
Object values can be modified, whereas types as numbers, strings and Booleans are immutable.

Second Part:

1. Why can’t you add new properties to a string variable?
Because just variables of object type receive new properties.

2. What are rest parameters?
Are parameters that accept any number of arguments. The function’s last parameter with three dots before is a rest parameter.

4. What is serialisation and what is a use case of serialisation of data?
Serialisation is the process that convert the memory’s variables to a flat description that after can be storage or sent to another place.

5. What is JSON?
Is a popular serialization format and is 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 format, 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.