Data Structures (Arrays and Objects) - Reading Assignment

  1. A valid way of storing multiple variables was needed.
  2. Arrays store multiple sets of data.
  3. Properties express the values and can be accessed with a . or [].
  4. nul and unidentified.
  5. . or [].
  6. The function value in the property.
  7. Objects are an arbitrary collection of properties, to create objects use brackets as an expression.
  8. Objects enable us to collect and hold different data types.
  9. contain list of values within the brackets [“1”,“2”].
  10. Strings and booleans are immutable but you can change the properties within objects, causing the value to alter.

PART 2.

  1. Strings are not objects and are immutable.
  2. The rest parameter is called with ‘…’ before the functions last parameter, the rest parameter is bound to all further arguments in the array.
  3. Converted data stored in memory into a flat description.
  4. JavaScript Object Notation is a format used for data storage.
  5. Property names need to be surrounded in double quotes.

PART 1

1. The problem presented by the weresquirrel situation is finding a way to store the variety of data needed. A String stores only a series of characters… An integer stores numbers.

2. An array is used to solve the problem. It is possible with a string or an integer but the process would be laborious The better choice is to use an array as a variable type.

3. Properties in JavaScript is derived from the definition of property as being " an attribute, quality, or characteristic of something". Properties in JavaScript are accessed from a value using an expression such as: myString.length .

  1. While most values have properties null and undefined do not. Using either of these as a property will produce an error.

  2. Properties in JavaScript are mainly accessed two ways by using a dot or square brackets. The choice has to do with interpretation. The dot has to do with the literal or exact name of the property. The square brackets deals with what is in the expression between the brackets You might say that the dot is the property and the square bracket evaluates the property.

  3. Methods in JavaScript has to do with the procedure of the property relative to the indicated value. When the property contains a function or functions it becomes a method or how the value will proceed. The method is what the function does. One instructor wrote, "Methods are the functions that let the object do something or let something be done to it."

  4. In JavaScript almost everything is an object. Objects are a collection of properties. The values of the collection of properties are arbitrary. However, you may create your own. The objects can be modified.

  5. The problem solved by objects is the ability to store different sequences of values. This object is called an array .

  6. Objects are a collection of related data and/or functionality. They usually consist of several variables and functions.

  7. A mutable object is an object whose properties can be modified after it is created Examples of some JavaScript values that are mutable include objects, arrays and functions. Strings, numbers and Booleans are examples of values that are immutable or cannot be modified.

PART 2

  1. You cannot add new properties to a string. Strings are immutable and new properties cannot be added to them because they are not objects. But string values have other methods of built-in properties that can be used that resembles the array. However these properties are constant.

  2. The rest parameters allows us to access an indefinite number of arguments as an array. This is accomplished by placing three (3) dots inside the parenthesis () before the last parameter of the function. Any parameters listed before the three dots are not considered as part of the array. There is also the spread operator that uses the same basic action to add and copy elements into an existing array.

  3. (Reading Instructions)

  4. Serialization is taking a complicated and sometimes lengthy block of objects and arrays and converting it into a string. These are in your computer’s memory in such a way that makes it difficult, if not impossible, to send it to another computer sequentially over the network. In order to do that it must be translated into a stream of bits. The data can also be serialized and saved into a file for later use.

5.What is JSON? In order to accomplish the transmission of the data it must be converted into a flat description array… Javascript has provided a serialization format for this purpose called JSON. It is a storage and communication format designed for the Web. The function JSON.stringify and JSON.parse in the code will convert the data to and from that format.

  1. JSON and Javascript are similar in language but because JSON is sent over HTTP it is being transmitted as plain text and not as a programming construct. Consequently JSON has to be in a more consistent form. All property names have to be surrounded by double quotes. Only simple data expressions are allowed. No actual computations are allowed. Neither are comments

Part One:

  1. If we want to store chunk of data for example collection of numbers like 2,3,4,5,and 10. If we use string for representing those no’s then the string like “2 3 4 5 6 10” but we are unable to get back the numbers from the string. So by using string or integer we are unable to store chunk of digital data.
  2. Arrays
  3. All JavaScript values having properties. ex. myString.length access the length property of value myString. Math.max aceess the max property in the Math object.
  4. null and undefined
  5. first: value.x here x is property name. second: value[x] here x is expression so after solving the expression we get the property name.
  6. Property that contain function called methods
    ex: let doh = “Doh”;
    console.log(doh.toUpperCase());
  7. Different types of values we can store in single objects.
  8. We can store number, string and Boolean values in single object.
  9. arbitrary collection of properties
  10. JavaScript object values are changeable so called as mutable.
    ex: let object1 = {value:10}
    object1.value =15;

Second Part:

  1. If we define the new property to the string it does not store so we can’t add the new property to the string
  2. for writing the function three dots are used before the functions last parameter.
    let numbers = [5, 1, 7]
    console.log(max(…numbers));
    // 7
  3. serialization means flat description of data. it is used for data storage and communication on the web.
  4. JSON is JavaScript Object Notation. It is a format for data storage and communication over the internet.
  5. All property names in JSON are surrounded by double quotes, only simple data expressions are allowed, comments are not allowed in JSON.

PART 1

  1. Storing a sequence of values
  2. Array
  3. Properties are pre-defined values that are accessed thru expressions.
  4. Null and undefined are two values that could not have properties.
  5. We can access properties in JavaScript with a dot and with square brackets. 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. Methods are properties that contain functions.
  7. Objects are values that are arbitrary collections of properties.
  8. Properties of objects can be changed, thus, they are mutable. Integers, strings and boolean expressions are immutable.
  9. You define an object by following the binding with braces. Inside the braces is a list of properties you want to assign, separated by commas.
  10. Objects’ properties can be changed, causing a single object value to have different content at different times. Also, there is a difference between having two references to the same object and having two different objects that contain the same properties. In the former case, if you create a new object by equating it to an existing one, any change made to either one of them would change the other. If you define 2 objects separately, they are not equal even though you begin by assigning the same properties inside each.

PART 2

  1. A string variable is not an object, thus, it doesn’t store any other property other than what’s inherent of its type.
  2. Rest parameters allow evaluation for any number of arguments. It can also evaluate each content of an array or allow its contents to be spread out.
  3. I still read this, thanks for the concern.
  4. Serialization is conversion of data into a flat description. This is done to save data for later access, and also to share it over the network.
  5. JSON stands for JavaScript Object Notation, widely used as a data storage and communication format on the Web.
  6. In JSON, property names have to be surrounded by double quotes. JSON has restrictions, such as only simple data expressions are allowed - no function calls, bindings or computation. Comments are also not allowed.

Hi @ivan and community,

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

The problem in the chapter is about objects. The problem can’t be solved with only using native datatypes like char, String or int. The combination of them is the key to success. To be able to create objects that are existing for example of several Strings and int- or float-variables, is the goal of this chapter.

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

A array or a list can hold several objects that are type of different datatypes.

  1. What are properties in Javascript?

Properties are additional informations about values in the script / program. For example, “length” is a property of an array.

  1. Which values do not have properties?

“null” and “undefined”.

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

“value.” or “value[‘propertyName’]”

  1. What are methods?

Methods are code that can be executed on objects or directly in the body of a HTML document. Methods can read, manipulate and delete variables.

  1. What are objects?

Objects are a collections of several and different datatypes combined into a centralized structure.

  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 by far more complex as native datatypes and therefore, more complex tasks are able to do and more complex problems are able to solve due to objects. Furthermore, when creating objects the programmer can create own methods that can be executed on the objects, which leads to a powerful way to data management.

  1. How do you define an object?

var myObject = {name: “red”, size = 10}
Objects are defined as any other datatype.

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

Important is to differentiate between the references to a variables and the value the reference is pointing at. Two different references, which means two different objects, can hold the same value.

+++++++++++++++++
++ SECOND PART++
+++++++++++++++++

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

They have no properties because they are no objects. They are built-in native datatypes of JavaScript. They have built-in functions like “slice()” or “indexOf()”.

  1. What are rest parameters?

The rest parameters makes it possible to create functions with variable length of the input parameters.
function getMax(…numbers) { return 0 };
// getMax(1,2); getMax(3,5,8,6); getMax(2,3,4,5,6,7,9,9);

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

I don’t skip anything! =D

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

Serilization is the process of storing informations from objects of a running application in a normalized format like JSON.

  1. What is JSON?

JSON is a standard, a norm, a datatype which is used to send data in a performant manor through the network. This format is widely used to do communication between different computers.

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

Only simple text and format is allowed in JSON. No function, no bindings, no comments. The receiver need to information how to interpret the received JSON file.

Cheers
OtenMoten

  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 analyze sequences of values and how many times they appear in a given set of instances. I think that’s what it means?

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

Arrays. They can store multiple data types and call them individually, like a weapons array.

  1. What are properties in Javascript?

They are the units in which values are stored in an array. When using .x, where x is the name of the property, the array will pull the exact literal value of x, which if you do [x] or [“x”] in the case of a name or something, it’ll run it through, evaluate, and just pull the value.

  1. Which values do not have properties?

Null and undefined.

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

.x and [x]

  1. What are methods?

Properties that contain functions are called methods.

  1. What are objects?

Objects are arbitrary collections of properties that can later be analyzed using if else booleans and stuff? Like in the weresquirrel example. Object groups of possibilities as to why he turned into a weresquirrel.

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

It’s able to store a list of values along with Boolean if else results for them.

  1. How do you define an object?

So, you start off with { then you list the overlying boolean value which true or false. Then announce the area and put : at the end, then list the array’s properties inside square brackets like so [“x”,“y”] and so forth. Then yo close the whole object with }; as usual. Then you run it and profit.

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

I’m not sure if I quite get it, but apparently objects are mutable in the sense that the properties within objects can be modified and cause them to refer to different things at different times? Not sure lol.


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

These values are immutable and cannot be changed, unlike properties in arrays.

  1. What are rest parameters?

I don’t quite get it. But I understand that it has something to do with gathering all the rest of the parameters and arguments into the array, like including them all, just like an etc kind of function the English language.

  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?

JSON, basically how stuff and arrays and shit are written out in JS.

  1. What is JSON?

The way we learn to write out arrays in JS but with some restrictions.
“squirrel”: false,
“events”: [“property1”, “property2”, “property3”]
};

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

You can’t put comments, all property names must be surrounded by double quotes, only simple data expressions allowed, no function cells, bindings, or anything that involves actual computation.

  1. The sub-chapter weresquirrel introduce a problem where variables like strings can only hold one type of data.
  2. Array is a variable type that can be used to solve the problem of storing multiple values.
  3. Properties like length, values, and index in Javascript define certain characteristics
  4. Undefined and null variables don’t have properties.
  5. Properties can be accessed by either using square brackets [ ], or by using dots like array.length
  6. Methods are properties that hold function values. They are special kinds if functions that only work on the value they belong to.
  7. Objects are collections of properties, users can store different value types inside of them.
  8. Objects can store different types of values, such as booleans, strings, integers, and arrays.
  9. Objects are defined like other variables, but with the value contained inside braces.
  10. Javascript object values can be changes

Second Part

  1. String valuables are immutable
  2. Rest parameters are the use of any number of arguments
  3. Great
  4. JSON is short for JavaScript Object Notation. It’s a serialisation format that is widely used for data storage.
  5. JSON is different from the way programmers write objects in plain Javascript because, no bindings, function calls, or anything that requires computation. All property names need to be surrounded in double quotes and only simple data expression.

First Part:

  1. A variable type is needed that can present a sequence of data.
  2. Arrays
  3. The properties of an object determine its characteristics.
  4. Null and Undefined
  5. You can access the property of an object using dot recording: .name .length .age …and with square brackets: value[x]
  6. Methods are properties that contain functions.
  7. Object are arbitrary collections of properties, are declared using curly braces {…}
  8. Object contain of different value types.
  9. var user = { name: “Julia”, age: “25”, friends: [“Alex”, “Adele”, “Peter”], new: false };
  10. Objects can change their properties, causing a single object value to have different content at different times.

Second Part:

  1. Because it is not object, it is immutable and cannot be changed. It have built-in properties.
  2. The rest parameter syntax allows us to represent an indefinite number of arguments as an array.
  3. Serialization is the process of converting an object in memory to another format that can be used to store it in a file or send it over a network.
  4. JSON is serialization format, understandable to almost any other language (Javascript, Java, C #, C ++ …)
  5. Comments, functions, bindings are not allowed in JSON. All property names have to be surrounded by double quotes.
  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?
    Massive amount of data cannot be stored and evaluated as efficiently as objects structures with arrays.

  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 the values of an Array

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

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

  6. What are methods?
    Property functions are called methods

  7. What are objects?
    Objects are sequence of data. It can store boolean, integers, strings

  8. What problem do objects solve that cannot be solved with other value types we’ve learned so far (such as integer, string, array, boolean etc)?
    It includes boolean variables that arrays cant.

  9. How do you define an object?
    Let objectname = { }

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

Think about the following questions:

  1. Why can’t you add new properties to a string variable?
    JS only supports some inbuilt properties. New properties doesnt stick.
  2. What are rest parameters?
    Three dots that allows us to free the function from input limits
  3. (Feel free to skip the sub-chapter of Math object and Destructing)
  4. What is serialisation and what is a use case of serialisation of data?
    Converting objects to a flat description.
  5. What is JSON?
    Javascript object notation. A widely used communication format on web.
  6. What are the differences between JSON and the way programmers write objects in plain Javascript?
    Comments are not allowed. Property names are surrounded by double quotes. Functions are not allowed. Only simple data descriptions will be given
  1. It required to store many values in a single binding.
  2. Multiple values can be stored in a array.
  3. Properties are some features or functionalities that a value provides and can be accessed when required.
  4. null and undefined.
  5. we can access the properties by using a . or a [ ].
  6. The properties that have function as a value are called methods.
  7. Objects are arbitrary collections of properties.
  8. Objects can contain multiple properties in a single binding and each property can be accessed as per the requirements.
  9. Objects are defined in the same way as the other variables but the value is wrapped inside braces { }.
  10. The properties of an object can be changed in javascript but they are different from the properties of some other object.

Part 2

  1. Strings are immutable therefore we cannot add new properties to them.
  2. In rest parameter the number of arguments are not fixed. We can pass an array as an argument.
  3. Serialisation means to convert data into a flat fdescription.
  4. A popular serialization format is called JSON.
  5. JSON looks similar to JavaScript’s way of writing arrays and objects, with a few restrictions. All property names have to be surrounded by double quotes, and only simple data expressions are allowed—no function calls, bindings, or anything that involves actual computation. Comments are not allowed in JSON.

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

For this occasion we need to collect multiple variables and organise them. A simple string or integer variable can not represent such information itself.

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

An array can be used to store a sequence of multiple variables.

3. What are properties in Javascript?

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. Which values do not 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

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

For example:

console.log(doh.toUpperCase());

// → DOH

7. What are objects?

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

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

With Objects we can store sequences of multiple different value types.

9. How do you define an object?

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 values numbers, strings, and Booleans, are all immutable. Compared to this object values can be modified. Their properties can change their value.

Second Part:

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

A string varible doesn’t actually store properties, which you would like to add like for objects. The values numbers, strings, and Booleans, are all immutable.

2.What are rest parameters?

The rest parameters gather all the remaining values in an array.

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?

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

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.

  1. Variable types such as strings and integers are only able to hold a single type of data. What our friend needs is a data structure that is capable of storing multiple values and data types in order to keep all of the information organized.

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

EXP: let listOfNumbers = [2, 3, 5, 7, 11];

3.Properties (quality that something has), define some characteristic about the values in a data structure, such as the length of an array or the index of a value.

  1. null and undefined are exceptions with no properties.

  2. Access to properties has two main ways value.x and value[x].
    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.

  3. Properties that contain functions are generally called methods **(things they can do).

  4. Objects are arbitrary collections of properties and methods that called functions.

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

let day1 = { squirrel: false, events: [“work”, “touched tree”,“pizza”,“running”}

Braces in java script mainly used to describe an object.

  1. Value type such as string, array and Boolean are not objects those are primitive type as such they can´t be expanded to properties and method like an object.

  2. Objects in JS are the same as objects in real life they can have qualities and things they can do.

10.The mutability of Javascript objects means that the values they contained can be changed.


  1. Those values are immutable and cannot be changed.

  2. When you pass an argument use spread operator (…n) that´s called rest parameter.

  3. Serialization means data structure converted into a flatten String.

It´s necessary that data would be translated into stream of Bits that we can send it over connection and then the recipient will serialize it and reconstruct an object.

  1. JSON stands for JavaScript Object Notation used as a data storage and communication format on the Web.

  2. JSON looks similar to JavaScript’s way of writing arrays and objects, with a few restrictions. All property names have to be surrounded by double quotes, and only simple data expressions are allowed—no function calls, bindings, or anything that involves actual computation. Comments are not allowed in JSON.

  1. To store multiple values.
    2.Objects and Arrays
    3.Properties are the values associated with a JavaScript object.
    4.null and undefined

  2. The syntax for accessing the property of an object is:

objectName.property

or

objectName [" property "]

or

objectName [ expression ]

The expression must evaluate to a property name.

  1. JavaScript methods are actions that can be performed on objects. A JavaScript method is a property containing a function definition.

  2. Objects are defined as any other variable, with the value being a list contained within braces.
    8.Store different data types.

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

  4. Unlike numbers, strings and Booleans, which are immutable values, objects can be modified. Objects can have their properties changed, causing a single value to have different value at a certain moment in time

Second Part:

  1. It is immutable.
  2. Rest parameters accept any number of arguments. The notation includes the ellipsis (…) to represent an array of all arguments to be included.
  3. Serialization 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. This allows us to use JSON notation to convert data between data types, from string to the value it holds and vice versa.
  4. Only simple expressions are allowed in JSON. There are no functions, bindings, comments, or computations.all property names have to be surrounded by double quotes.
  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?
    Processing collections of data.

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

  3. What are properties in Javascript?
    So that less variable names need to be used up.

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

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

  6. What are methods?
    Properties that perform functions

  7. What are objects?
    Groups of data like name and age.

  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)?
    Allows the storing or multiple data types together

  9. How do you define an object?
    { }

  10. What can you say about the mutability of Javascript objects?.
    The values can be changed during the flow of the program

Think about the following questions:

  1. Why can’t you add new properties to a string variable?
    It’s only a single item where as an object is like a box of variables

  2. What are rest parameters?
    Allows you to add as many array items as needs and not predefined

  3. What is serialisation and what is a use case of serialisation of data?
    So data can be used else where.

  4. What is JSON?
    JavaScript Object Notation

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

Format of how data is stored in memory

Initial questions:
1. Read the sub-chapter called The weresquirrel. What problems does this chapter introduce that cannot be solved with variable types such as strings or integers?

  • The problem is that strings and integers can only store one type of data/values, while an array can store multiple types of data/values.

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 expressions to access specific values associated with JS objects.

4. Which values do not have properties?

  • null and undefined.

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

  • object1.property and/or object1[“property”]

6. What are methods?

  • Methods are properties that act as functions.

7. What are objects?

  • Objects are variables that contain an arbitrary 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)?

  • Objects can store multiple values of different data types in the same variable in a convenient way.

9. How do you define an object?

  • newObject = {value1: X, value2: “Y”};

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

  • JS objects are mutable, which means that their values can be modified. Other variables, such as numbers, strings, and booleans are immutable.

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

  • Because it is not an object and therefore it is immutable.

2. What are rest parameters?

  • Rest parameters are bound to an array and can represent an unspecified number of arguments

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

  • I went through these sub-chapters :wink:

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

  • Serialization is storing your data structures to a transfer compatible format. You can use serialisation to transmit data to other computers.

5. What is JSON?

  • JSON means JavaScript Object Notation and it is a standard used in data storage and communication.

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

  • JSON is used to store simple data expressions and cannot store functions and computation performing expressions (no comments, functions, binds…). When using JSON, all property names need to be surrounded by double quotes.
  1. This chapter introduces the problem of storing sequences of values that could be easily accessed and modified.

  2. To solve this problem, one can make use of arrays.

  3. Properties are a kind of characteristic that values have in JavaScript.

  4. The values null and undefined do not have properties in JS.

  5. You can access properties in a value by using the dot or by using square brackets.

  6. Methods are properties that contain a function.

  7. Objects are basically a collection of property bindings, that is, properties that are created by the user and put together as an array.

  8. Objects can store a list of different data types into a single value.

  9. You can define an object by listing properties separated by a comma, and closing all inside two braces. Each property has a name, followed by a colon and a value.

  10. Objects, unlike other values such as numbers, strings and booleans, are values that can be modified. That is, they can store different values at different points of time.

  11. You can’t add new properties to a string variable because strings are not objects. They only have built-tin properties.

  12. Rest parameters can be used to make a function accept any number of arguments, and also can be used to call an array and spread it into separate arguments.

  13. ok

  14. JSON is a popular serialization format used to store data to convert a memory address into a description that can be stored or sent. This allows to easily send information without actually sending the entire memory of the computer.

  15. The main differences are the need to use double quotes for property names and the restriction to only simple expressions, that is, no function calls, binding or anything that involver actual computation.

  1. Weresquirrel: What problems does this chapter introduce that cannot be solved with variable types such as strings or integers?
  • A data structure that is capable of storing multiple values is required.
  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 additional pieces of information / characteristics that can be accessed.
    Ex: myString.length - to get the length of a string
    Math.max - to get the highest number in a list of numbers
  1. Which values do not have properties?
    Null and undefined are values that do not have properties.

  2. How can we access properties in a value?

  • The two main ways to access properties in JavaScript are with a dot
    value.x
    and with square brackets
    value[x]
  1. What are methods?
  • Methods are functions that live in properties and (usually) act on the value that they are a property of. In other words, methods are properties that contain functions.
  1. What are objects?
  • Values of the type object are arbitrary collections of properties.
  1. What problems do objects solve that cannot be solved with other value types we’ve learned so far?
  • Objects allow us to group values - including other objects - to build more complex data structures.
  1. How do you define an object?
  • Curly braces are apparently used to delineate an object. Inside the braces, there is a list of properties separated by commas. Each property has a name followed by a colon and a value.
  1. What can you say about the mutability of JavaScript objects?
  • You can change the properties of JavaScript objects, causing a single object value to have different content at different times. This is not possible with numbers, strings, and Booleans (which are immutable).
  1. Why can’t you add new properties to a string variable?
  • If you try to add a new property, it does not stick (it does not store the new property).
  1. What are rest parameters?
  • It is a parameter written last in the code line preceded by three dots (…). It refers to the “rest of” (remaining) arguments.
  1. What is serialization and what is a use case of serialization of data?

  • Serialization is the conversion of data into a flat description.
    use case: JS properties grasp values rather than contain them. Information such as objects and arrays, are stored in the computer’s memory by their addresses (not their actual values). If you want to save the data file or send it, you would be dealing with tangles of memory addresses. A solution is to serialize the data.
  1. What is JSON?
  • JavaScript Object Notation.
    It is a type of serialization format.
  1. What are the differences between JSON and the way programmers write objects in plain JavaScript?
  • JSON has a few restrictions:
    All property names have to be surrounded by double quotes.
    Only simple data expressions are allowed.
    No function calls, bindings or anything that involves computation.
    Comments are not allowed in JSON
  • My question to anyone who might read this:
    In the current Chapter 4 (Eloquent JavaScript), on page 3, lines 13 and 14 are as follows:
    console.log(listOfNumbers[2-1]);
    // -> 3
    It is talking about arrays. In position 2 of the array, there is 5. In position 1 of the array, there is 3. This is considering that the first position is 0.
    Why is the answer 3 and not 2? (5 minus 3 = 2)
    Thank you in advance.
  1. It teaches us about working with data sets i.e. working with and operating on multiple data pieces. With what we’ve learned until now, we can only work with single data entries, and this severely limits our flexibility in programming.

  2. An array does precisely this.

  3. It is an association between a variable and an expression that describes it in some way. It tells us something about that variable.

  4. Null and undefined

  5. Either by the format “variable.property” or " variable [“property”] ". In the first case, the term “property” must define exactly the property we seek, whereas in the second case, the property is determined by the result of the operation inside the square brackets.

  6. When a property comes in the form of a function, it is called a method. It is a property whose result required a computational operation to obtain.

  7. From my understanding, I noted it down like this:
    An array is a multitude of values.
    An object is a multitude of associations between values and their specific property.
    I know the book tells us an array is a type of object (and I see it as the array elements are not
    associated with anything specific more than their index), but this way of seeing it helps me see it
    clearer and fix it in my brain.

  8. It helps us work with multiple sets of data at the same time and operate between them. Basic variables can be seen as atoms, while objects can be seen as molecules. We can do more complex “chemistry” when we have objects to work with.

  9. It hold a series of elements with their specific property asociated to them.

  10. You have to differentiate between changing the object itself and changing its contents. If you change the elements of object B as to coincide with those with object A, the two objects will still be considered different, and the boolean object A == object B will return false.

SECOND PART:

  1. You can’t add properties because strings are basic variables and they are immutable, unlike objects.

  2. They are a way of using an array as a function argument, without writing the whole array. By writing the format “…array” JS will know we want to use all the elements of array[] as argument to our function. Array is defined the moment we call the function and write it’s arguments in square brackets.

  3. Serialisation of data is a way of using less memory for storing info about variables.

  4. It is a popular serialisation format that stands for JavaScript Objet Notation. It’s pretty much the same as plain JavaScript, only that it can’t have computational statements, such as functions.

  5. In JSON you need to always use double quotation marks “” and, as mentioned aboved, only non-computational expressions are allowed.

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?
    Mr Weresquirrel needs a way of storing multiple variables at the same time in order to keep his log.

  2. What variable type can be used in order to solve the problem of storing multiple values?
    An array would allow for multiple values to be stored in one data type

  3. What are properties in Javascript?
    Properties are characteristic of values in a data structure

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

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

  6. What are methods?
    Properties that contain functions such as “toUpperCase”

  7. What are objects?
    Objects are datastructures consisting of aribitarary 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 store different kinds of values in one value.

  9. How do you define an object?
    let objectA = {a: 1, b: 2};

  10. What can you say about the mutability of Javascript objects?
    Mutability as the name suggest is the characteristic of a datatype that allows it to be changed or modified after it has been declared.objects are mutable.

  11. Why can’t you add new properties to a string variable?
    They are a primitive type, which are immutable

  12. What are rest parameters?
    Passing a Rest paramenter to a function as argument allows us to pass infinite number of arguments as array. Rest parameter has a specific syntax e.g. argument prefix by three dots (… theArgs) function calPercentage(percentage, …theArgs)

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

  14. What is serialization and what is a use case of serialization of data?
    Serialization is converting data like objects or arrays and convert into a flat description in order to be saved or sent to another computer.

  15. What is JSON?
    JSON is a serialization format, it’s used as a data storage and commucation format on the web and looks similair to JavaScript with a few restrictions.

  16. What are the differences between JSON and the way programmers write objects in plain Javascript?
    JSON looks similar to JavaScript’s way of writing arrays and objects, with a
    few restrictions. All property names have to be surrounded by double quotes,
    and only simple data expressions are allowed—no function calls, bindings, or
    anything that involves actual computation. Comments are not allowed in
    JSON.

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

Here we want to create a collection of values from the same type. Doing so with integers is not possible, because putting together several numbers in such a manner would just be saved as a number itself, we wouldn’t be able to retrieve the individual values. Doing it with integers is highly difficult, because a sequence of numbers becomes a string of text and retrieving the values requires heavy lifting.

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

This problem is solved using an array, where several values of the same type are stored in a single variable that can then be called back. It and is written as a list of values between square brackets, separated by commas.

3. What are properties in Javascript?

They are values associated with an object or array. They are defining characteristics such as the length, its maximum or the place, or index, an element is in an array.

4. Which values do not have properties?

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. For example value.x or value[x]. Using value.x makes you access the property x of value. For example value.length gives you the length of value, value.color gives you the color of value. When using brackets, what is between the brackets is evaluated and uses the result, converted to a string as the property name.

6. What are methods?

Methods are a properties that contain a function. They are linked to a value of the array. For example, array.push(X) will push the value in parenthesis to the array. .toUpperCase will put a text in upper case.

7. What are objects?

Objects groups values into a single variable and those values can be of different types

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 store values and have properties of different types, whereas other datatypes, including arrays, cannot.

9. How do you define an object?

They are declared using braces:

let day1 = {
		squirrel: false,
		events: ["work", "touched tree", "pizza", "running"]
	};

Each property is separated by a coma. It is declared using a name ( for example squirrel), from its value separating it from its value (: false).

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

You can change the properties of objects, causing a single object value to have different content at different times. Comparing two different objects using == will give you false always because objects are different in JS. The objects are compared, not their values.

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

Adding new properties to a string variable would equate changing the string and strings are immutable in JS.

12. What are rest parameters?

Rest parameters tell a function to accept all arguments it is given, instead of a fixed set as we have seen up until now. It can also be used to spread out an array into a function call, letting the function operate on the entire array. It can also be used to spread an array into another array, as in
let words = [“never”, “fully”];
console.log([“will”, …words, “understand”]);
// → [“will”, “never”, “fully”, “understand”]
To use a rest parameter, use the three dots as above.

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

Giving a flat description of the data. Doing also enables communication between different programs, something hard to do otherwise, as the objects we build in JS and their properties are stored in adresses of the memory.

14. What is JSON?

JavaScript Object Notation, it is a serialization format, a very popular data storage and communication format.
You can iterate over arrays using a special kind of for loop— for (let element of array) .

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

In JSon properties have to be in double quotes, not in JS, and the expressions allowed are only simple data. no functions, bindings or computation is authorized. JS let’s you do all of that