Data Structures (Arrays and Objects) - Reading Assignment

  1. There are too many changing values in this text for using strings or integers
  2. It is called an array and is written as a list of values between square
    brackets, separated by commas
  3. Properties are the values associated with a JavaScript object . A JavaScript object is a collection of unordered properties.
  4. Null and undefined
  5. With a dot OR with square brackets
  6. JavaScript methods are actions that can be performed on objects.
  7. Almost “everything” is an object. Booleans can be objects (if defined with the new keyword) Numbers can be objects (if defined with the new keyword) Strings can be objects (if defined with the new keyword) Dates are always objects. Maths are always objects. Regular expressions are always objects.
  8. You can store different values in one object
  9. by using braces as an expression
  10. Mutable object is an object whose state can be modified after it is created.
    Immutables are the objects whose state cannot be changed once the object is created.

SECOND PART / Strings and their propertiees

  1. Because strings and numbers are Immutable
  2. Rest parameters are used to create functions that accept any number of arguments
  3. The process whereby an object or data structure is translated into a format suitable for transferral over a network, or storage (e.g. in an array buffer or file format). In JavaScript , for example, you can serialize an object to a JSON string by calling the function JSON. stringify()
  4. JSON - JavaScriptt Object Notation… Is a format for storing and transporting data. JSON is often used when data is sent from a server to a web page.
  5. JSON is detailed as a lightweight data-interchange format. JSON looks similar to JavaScript’s way of writing arrays and objects, with afew restrictions.
2 Likes
    1.What problems does this chapter introduce that cannot be solved with variable 
   types such as strings or integers?

Building more complex Data Structures. Objects allow us to group values. Arrays also are a kind of
object specialized for storing sequences fo things.

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

Arrays are a type of variable to store multiple values, seperated by commas.

3.What are properties in Javascript?

They are expressions that access something of some 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)?

We can access properties with a dot and with square brackets.

6.What are methods?

properties that hold function values.

7.What are objects?

Data structures with 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 of grouping these single data together into grouped values as an array.

9.How do you define an object?

you defined it by using a binding. then followed by curly braces {}

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

You can change their properties. Values can have different content at different times.

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

They are not objects. Values in a string are immutable and connot be changed.

 12.What are rest parameters?\

Used for a function to accept any number of arguments. bound to an array.

(Feel free to skip the sub-chapter of Math object and Destructing)
 13.What is serialisation and what is a use case of serialisation of data?

Serialization is Data converted into a flat description. We use it as a data storage and
communication format on the WEB. Used also in languages other than JavaScript.

  14.What is JSON?

Similar to Javascripts way of writing arrays and objects but with a few restrictions. All
properties are surrounded by double quotes. It is used as a format cummunication on the WEB,
for other languages.

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

NO comments allowed. Property names are double quoted. no function calls, bindings or actual computation

2 Likes
  1. What problems does weresquirrel introduce that cannot be solved with variable types such as strings or integers?

Storing a lot of 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?

Length, max.

  1. Which values do not have properties?

Null and undefined

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

value.x and value[“x”].

  1. What are methods?

Methods are properties that contain functions.

  1. What are objects?

Objects are variables that can contain many values

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

Object values can be modified. The values of numbers, strings, and Booleans, are all immutable—it is impossible to change values of those types.

  1. How do you define an object?

Object is a type of value that are arbitrary collections of properties

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

Objects are the same only if they have the same identity. The same value does not mean that they are the same.

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

New properties cannot be added to String because Javascript does not consider those values as objects and it does not store those properties.

  1. What are rest parameters?

Rest parameter gives a function the opportunity to accept any number of arguments.

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

Serialization is data conversion to a flat description.This is used to send your data to another computer or to use it later without sending all your computer memory.

  1. What is JSON?

Javascript Object Notation. It is used as a communication format and to store the data. This format is used also for other programming languages, not only Javascript.

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

Comments, function calls, bindings and other expressions that involves actual computation are not allowed.

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?
    We need to store different(strings, integers, floats, arrays) sets of information seen as an octopus
  2. What variable type can be used in order to solve the problem of storing multiple values?
    An array
  3. What are properties in Javascript?
    they are characteristics in a value
  4. Which values do not have properties?
    Null, undefined
  5. How can we access properties in a value (two ways)?
    a) value.propertie
    b) value[“propertie”]
  6. What are methods?
    Properties of a value that are functions
  7. What are objects?
    A set of properties attached as an octopus
  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 the same entity and is more abstract, for example i can store any activity I did on a regularly bases on an object
  9. How do you define an object?
    let ObjectName = {
    // properties (functions, strings, arrays, etc)
    }
  10. What can you say about the mutability of Javascript objects?
    They are mutable in other words you can change the content easily.

SECOND PART:

  1. Why can’t you add new properties to a string variable?
    For the inmutability is impossible
  2. What are rest parameters?
    You can pass any arbitrary number of parameters into a function. For example ypu can create any function than calculate the average of any quantity of numbers
  3. What is serialisation and what is a use case of serialisation of data?
    convert data into a flat description
  4. What is JSON?
    its a way of serialization and not only works for javascript but also for any other languages.
  5. What are the differences between JSON and the way programmers write objects in plain Javascript?
    The names will be surrounded by quotes, you cannot put anything that need compute for example functions or calls.
1 Like

Multiple values need to be stored and so something other than strings or integers needs to be used.

Arrays

Properties are the given values of an object.

Null and undefined do not have properties.

The two ways to access properties is with a dot . and square brackets []

A method is a property containing a function definition.

Objects are variables that contain many values.

Objects are able to store many different types of data.

You define an object with an object literal, using {} braces as an expression.

Objects can have their properties changed once created and are therefore mutable.

Strings are immutable.

Rest parameters allow us to represent an indefinite number of arguments as an array.

Serialization converts data from a computer’s memory and value addresses into a flat description. Saving data in this way allows it to be easily shared across networks.

JSON is a serialization format used for storing data and communication online.

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.

1 Like
  • The problem of needing a data structure to store the information (log) of multiple values which can change. Using strings you would have to extract the digits and convert them to integers to access them. Variable types such as integers, strings, and Booleans hold single values, their values cannot be changed.

  • The variable type that we use to solve the problem of storing multiple values is called an array.
    An array is a *ist of values separated by a comma held by brackets
    let myArray = [1, 2, 3, 4];

  • Properties in JavaScript are variables attached to objects. They are the characteristics of an object, the values associated with an object. There are two kinds of properties instance and static.
    -Instance properties hold data specific to an object instance.
    -Static properties hold data that is shared with all object instances.

  • The values null and undefined do not have properties.

  • We can access the properties of an object by entering a dot after the object name.
    The word after the dot is the literal name of the property
    value.x also written as objectName.propertyName
    We can also access properties by using square brackets to get the value stored in the property
    value[x] also written as objectName[x]

  • Methods are properties that contain function values

  • An object is a variable with a collection of properties attached which define their characteristics.

  • Objects allows us to group together a bunch of values even different types and group them together into a single value.

  • You define an object by assigning it a value and then attach properties to the object.

var myCar = new Object();
myCar.make  =`Mini`;
myCar.model = `Cooper`;
myCar.color = `Blue`;

It can also be written with an object initializer

var myCar = {
    make: `Mini`,
    model: `Cooper`,
    color: `Blue`;
};
  • JavaScript objects are not immutable because you can change their properties which can cause the object value to be different at different times.

Two objects can have the same identifier and same properties but different property values. These objects will return false when trying to compare.


  • You cannot add new properties to a string variable because strings are not objects and their values are immutable and cannot be changed.

  • Rest parameters are a function which has three dots placed before the last parameter is bound to an array containing further arguments.

  • Serialization is to convert data into a flat description. It is used as data storage and communication format on the web.

  • JSON is a popular serialization format which stands for JavaScript Object Notation

  • Defference between JSON and plain JavaScript:
    -all property names have to have double quotes.
    -only simple data expressions allowed, no function calls, bindings, or anything that involves computation.
    -comments are not allowed

1 Like
  1. It solves the problem of adding, changing and sharing values over time.
  2. The array type.
  3. Properties are the values/data connected to objects.
  4. Null and undefined.
  5. The two ways of accessing properties of objects are: objectName.propertyName and
    objectName[“propertyName”].
  6. Methods are actions performed on objects. They are functions stored as a property.
  7. JS objects are variables that can contain many named values such as properties and methods.
  8. You can change an objects properties so it can have a different value at a different time. Also, different objects can point to the same value.
  9. You define an object with a list of name value pairs, literals, inside curly brackets.
  10. Objects work around the immutability and gives coding more possibilities.

SECOND PART

  1. Strings are immutable of primitive type.
  2. The three dot operator makes it possible to combine one array with a new array.
  3. :+1:
  4. Serialization is used to simplify storage. Keeping down the number of storage addresses and the storage size.
  5. JASON is a very popular serialization format used by various computer languages.
  6. The restrictions JASON has on JavaScript are:
    • You have to put property names within quotes.
    • Only simple data allowed, so no function calls, bindings or anything involving actual computing.
    • Comments are not allowed.
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?
    Many real-world problems cannot be modelled by discrete, simple data units but need a structure to model relationships among numerous units and types of data (analogous to how we present a set of interrelated data in a table).

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

  3. What are properties in Javascript?
    A property is a piece of information that describes a characteristic of an object or a value. For example, the length property of a string describes the number of elements (characters) that makes up the string.

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

  5. How can we access properties in a value (two ways)?
    If the name of a property is valid binding (variable) name, we can access the property with a dot notation, such as, “IvanOnTech”.length to get the number of characters in the string “IvanOnTech”. However, if the name of a property is not a valid binding name, such as “An important property”, we must use square brackets to access the property, for example, “IvanOnTech”[“An important property”]. The second method can be used on regular properties, such as, “IvanOnTech”[“length”] to get the length of the string.

  6. What are methods?
    A method is a property of a value that contains a function.

  7. What are objects?
    An object is 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 hold multiple custom properties whose values can be changed after initial definition whereas other simple data types have fixed properties and the values of those properties are predefined and immutable.

  9. How do you define an object?
    An object is defined by writing pairs of property names (keys) and property values within braces. For example, let anObject = {color: red, costs: 200}.

  10. What can you say about the mutability of Javascript objects?
    Values of data types other than object are immutable once defined. For example, the value of a piece of Boolean data can only be “True” or “False”, and they cannot be changed. The properties of an object, on the other hand, are mutable and make it possible the value of the object be changed over time.

SECOND PART:

  1. Why can’t you add new properties to a string variable?
    It is because JavaScript does not regard strings to be objects, so properties associated with strings are predefined and immutable.

  2. What are rest parameters?
    Rest parameters indicate a varied number of arguments passed to a function. Functions will accept all arguments contained in the rest parameter regardless of the total number of arguments.

  3. What is serialisation and what is a use case of serialisation of data?
    Serialisation is the process by which a data structure is translated into a descriptive format which is not connected to specific memory addresses in a computer. Serialised data can be easily transferred on a network and recreated on different platforms.

  4. What is JSON?
    JSON stands for JavaScript Object Notation. It is a widely used serialisation format on the Web.

  5. What are the differences between JSON and the way programmers write objects in plain Javascript?
    JSON has similar syntax as JavaScript but some restrictions. In JSON, all property names have to be inside double quotes and only simple data expressions are allowed – no actual computation is allowed inside the codes declaring properties. Also, comments are not allowed in JSON.

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

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

  3. What are properties in Javascript?
    They’re a values/data connected to objects

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

  5. How can we access properties in a value (two ways)?
    object.property
    or
    object[“property”]

  6. What are methods?
    Methods are properties that contains function values

  7. What are objects?
    Object is a variable with properties which define their characteristics.

  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 able to store many different types of data

  9. How do you define an object?
    with an object literal, using {} braces as an expression

  10. What can you say about the mutability of Javascript objects?
    Objects can have their properties changed once created and are therefore mutable

SECOND PART:

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

  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?
    Serialization is to convert data into a flat description . It is used as data storage and communication format on the web

  4. What is JSON?
    JSON is a popular serialization format which stands for JavaScript Object Notation

  5. What are the differences between JSON and the way programmers write objects in plain Javascript?
    -all property names have to have double quotes .
    -only simple data expressions allowed, no function calls, bindings, or anything that involves computation.
    -comments are not allowed

1 Like

PART 1

  1. The problem is, Jacques needs to switch to a more scientific approach by keeping a daily journal of everything. Unfortunately, strings and integers alone can’t do the work since there will be more information that he needs to log-in.

  2. We can use array. Array is a data type specifically for storing sequences of values and is written as a list of values between square brackets, separated by commas.

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

  4. Null and undefined are values that do not have properties.

  5. The two main ways to access properties in JavaScript are with a dot and with square brackets.
    Example:
    value.x
    value[x]

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

  7. JavaScript objects are data structures (with a standalone entity) that can contain collection of properties. For example, compare it with a cup. A cup is an object, with properties. A cup has a color, a design, weight, a material it is made of, etc. The same way, JavaScript objects can have properties, which define their characteristics.

  8. With the use of a JavaScript object, we can now store not just a number or a string but a list of unordered activities (like Jacques activities in the Weresquirrel problem) group together in a single value.

  9. An object is usually defined or created by using braces {}.

  10. JavaScript objects are mutable except for the primitive objects like numbers, strings, null, undefined and Booleans.

PART 2

  1. You can’t add a new property to a string variable because strings are immutable and adding properties to a string simply doesn’t stick.

  2. Rest parameter is an improved way to handle function parameter, allowing us to more easily handle various input as parameters in a function. The rest parameter syntax allows us to represent an indefinite number of arguments as an array. With the help of a rest parameter a function can be called with any number of arguments, no matter how it was defined.

  3. Serialization is converting data into a flat description. We need to understand that the computer saves the program as tangled memories of information. So serialization is important for programmers to save a file or send it to another computer or to another programmer rather than sending the whole memory of the computer.

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

  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 Like

First part:

  1. The problem of storing a data set, multiple values, in order to manipulate them.
  2. Arrays can store a collection of multiple values. Arrays are zero indexed.
  3. Properties are expressions that access a given characteristic of a value, such as .length, which would return the character length of the string type value it’s applied to.
  4. All JS values have properties with the exception of null and undefined.
  5. Properties can be accessed via dot notation, such as in the .length example above, or via square bracket notation, as in ["length"], where the string inside the brackets is evaluated to find the matching property.
  6. Methods are properties that contain a function description and can be performed on objects.
  7. Objects are data structures that allow us to group distinct values, including other objects.
  8. Objects allow us to hold many different data types together, rather than having them scattered as independent values.
  9. Objects are defined as other values in JS, with the collection of values inside curly braces separated by commas.
  10. Objects in JS are mutable, meaning that the values it contains can be altered. It is possible for an object to have different values at different times. Valus such as strings, booleans and integers, however, are inmutable and cannot be changed.

Second part:

  1. Because string values are inmutable. Fortunately, they do come with some prebuild properties.
  2. The rest parameter ... allows a function to take any number of paramareters, which are bound to an array when the rest parameter is called.
  3. Serialization allows us to gather data that is scattered through the memory and organize it into a flat description so that it can be stored or transfered.
  4. JSON stands for JavaScript Object Notation and it’s a popular serializtion format.
  5. Property names need to be double quoted and only simple data expressions can be included, not anything that involves any actual computation such as function calls. No comments are allowed in a JSON file.
1 Like

FIRST PART

  1. The problem with variables types such as strings and integers can hold only one type of values. In that case we need a structure that holds different types of values.
  2. Arrays can store multiple types of values
  3. In JS values have properties, that give some characteristic about values, ex: length or index
  4. Null and undefined values do not have any properties
  5. One way is: value.property - ex. array.length
    Second way is: value[“property”] - ex. array[“length”]
  6. Methods are properties that hold function values - can work only on the value they belong to.
  7. Objects are data structures that contain collection of properties of our choice
  8. Objects are able to hold many different types of data, as needed
  9. Objects are variables with the value defined in curly brackets, where properties are in colons, separated by comas
  10. Mutability of objects means that they are types of data that can be changed or modified after they have been defined. Unlike strings, numbers or booleans that are immutable.

SECOND PART

  1. We can;t add new properties to string, because strings are immutable
  2. Rest parameters can be accepted by a function with no defined numbers or parameters
  3. Serialisation convert data into a flat description of itself. This allow us to use JSON notation to convert data between data types, ex. from string to the value it holds
  4. JSON - JavaScript Object Notation - it is notation for data storage and communication.
  5. JSON requires double colon " " quotes for all property names. Also only simple expression are allowed in JSON (no function calls, bindings or even comments).
1 Like

Section1:
1&2.Jacques daily log consists of a set of data. Primitive value type such as string does not have the structure to store multiple values of different value types like an object does.
3. A property is a part of an object. Its a variable with a value attached to it.
4. Null and undefined have no property in Javascript.
5.

  1. object_name.property_name; Dot notation is clear and easy to use but has some limitation.

  2. object_name[“property_name”]; [] notation can access property name with special char. and format that dot notation can not accept. You can also access properties with variables using [].

  3. Method refers to any property with function as its value.
    7&8. An object is a data structure that can hold a collection of values of different types. You can access and manipulate an object’s data via its properties and methods.

let object_name={property_name1: value,
property_nameN: [value1,value2…valueN],
};

if value is a string or symbol value=“value”

10.JS objects are mutable. You can change any properties inside an object.

Section2:
1.JS string type values have some build-in properties and methods. These values can’t create any new Properties because they are not Objects.
2. rest parameter allows us to call a function with an infinite number of arguments. These arguments are bound to an array and can be managed and manipulated as an array.
4.data serialisation is a process that converts in-memory data structures into a flat description where it can be stored, transmitted and later restored to their in-memory form on another computer.
5&6. JSON(JavaScript Object Notation) a popular format for data serialisation. JSON is very similar to Javascript where all objects and arrays are transformed into strings via JSON.stringify() where all property names need to be in double quotation marks. JSON.parse(). change everything from JSON back to Javascript.

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?

Storing sequences of values - this isn’t possible with simple data types like strings and integers

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

Array

  1. What are properties in Javascript?

Properties of values. E.g. myString.length = the length of myString

  1. Which values do not have properties?

Null and undefined

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

With a dot (.) and square brackets.
value.x is going for the literal name of the property (x)
value[x] makes it so the expression x between the brackets is evaluated to get the property name. That is - the result of value[x], converted to a string, gives the property name.

  1. What are methods?

Properties that contain functions (e.g. .toUpperCase(), .push())

  1. What are objects?

Arbitrary collections of properties

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

With objects, we can group together many different values (even those of different types). We can also group these values into a single value

  1. How do you define an object?

By putting properties inside braces (curly brackets). Each property has a name, followed by a colon and value.

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

Unlike value types, such as numbers, strings, and Booleans, objects are mutable. This means you can change them by changing their properties.

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

They aren’t objects and can’t store properties

  1. What are rest parameters?

Rest parameters allow for the representation of an indefinite number of arguments as an array

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

Converting data into a flat description. Serialization is good for saving data in a file for later or sending it to another computer over the network

  1. What is JSON?

JavaScript Object Notation, or “Jason”. It is a popular data storage and communication format on the Web, even in languages aside from JavaScript

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

All property names have to be surrounded by double quotes.
Also, only simple data expressions are allowed - no function calls, bindings, or anything that involves actual computation.
Comments aren’t allowed.

1 Like

Data Structures: Objects and Arrays

  1. Read the subchapter called The Weresquirrel. What problems does the chapter introduce that cannot be solved with variable types such as strings and integers?

This chapter introduces the problems with storing and sequencing different types of information and being able to group different values together to build (and be able to work with) more or less complex data structures. Like keeping a log of different types of values into a single object that can later be used to, for example, run statistics with. This is a much simpler and more easily accessible way than to try and keep track of all the individual (but related) values separately.

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

Objects and arrays (which is a specific kind of object) both provide ways to group several values into a single value.

  1. What are properties in JavaScript?

Properties are the characteristics that a specific value type has access to, and pretty much all JavaScript values have them.
Properties are also what makes up objects. One way to look at properties in objects, is thinking of objects as being a “grab-bag” of sorts, containing a bunch of properties. Another way to understand properties (and objects), is comparing the objects to tangible, real world objects. Just about any tangible object you can thing of has properties. A car for example has properties like make, model, year of production, color, weight, max-speed, etc.

  1. Which values do not have properties?
  • Null and Undefined

  1. How can we access properties in a value?
  • 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. When using dot, the word after is the literal name of the property. When using [ ], the expression between “[ ]” is evaluated to get the property name. 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.
    So if you know that the property you are interested in is called “color”, you say value.color. If you want to extract the property named by the value held in the binding i, you say value[i]. Property names are strings. They can be any string, but the dot notation works only with names that look like valid binding names. So if you want to access a property named 2 or John Doe, you must use square brackets: value[2] or value [“John Doe”].

  1. What are methods?
  • Properties that contain function values are generally called methods of the value they belong to. Every string has an .toUpperCase method, that when called, returns a copy of the string that has all the letters converted to uppercase. There is also .toLowerCase, going the other way. There is a .push method, adding values to the end of an array, and a .pop method that when called, removes the last value of an array and returns it.

  1. What are objects?
  • Values of the type object are an arbitrary collection of properties. Or “an unordered collection of related data”, of primitive or reference types in the form of “key: value” pairs. For example “squirrel: false”.
    The “keys” can be variables or functions and are called properties and methods, respectively, in the context of an object.

  1. What problem do objects solve that cannot be solved with other value types we’ve learned so far? (Such as Integers, Strings, Array, Boolean etc?)
  • Objects are useful for making a single unit out of values that “belong together”, which allows for easier decomposing of a problem by collecting related values and their state. An object can contain any combination of primitive and reference data types whereas the primary types themselves (Integers, Strings, Booleans) only store a single value each.

  1. How do you define an object?
  • Defining an object is not much different from defining a variable. In a variable you create the name of the binding, an “equal to”-sign, followed by the value you want bind. When defining an object you do pretty much the same, exept that after the equal to -sign, you instead put curly brackets {…} and within them you start defining the (optional) properties of the object in the form of “key: value” pairs.
let person = {
	name: "Ivan"
	location: "Stockholm"
	title: "Big strong ivangelical cryptojesus"
}
  • Name, location and title in this example are the three keys of the three property names in this object. And “Ivan”, “Stockholm” and “Big strong ivangelical cryptojesus” - are the values of these keys (respectively).

  • The keys are strings, the values can be anything.

  1. What can you say about the mutability of JavaScript objects?
  • Object values can be modified, they are mutable. Which means that once created, their values can still be changed.
    JavaScript primitive value types, such as numbers, strings, booleans, null and undefined are immutable, it is impossible to change the values of these types.
    If you define animal = "cat", you can change the binding so that animal points to any other value, however, it is impossible to change or manipulate the value that animal points to. For example if you create some code to try to change the first letter in "cat" to make it spell out "rat" instead. The text inside that specific string will always remain the same. Your only option would be to make the binding you defined earlier, point to another string value instead.

  • Remember that in the book, bindings usually gets compared to octopus tentacles. They “grasps” different values, or rather, they grasp different memory addresses, containing a specific value. They don’t recreate the values held in these memory addresses.

  • Objects work differently. You can change the properties. A single object or object property can have different content at different times.

Part two:

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

Think about the following questions:

  1. Why can’t you add new properties to a string variable?
  • Because of the immutability we discussed in question 10, in the first part of this reading assignment questionnaire. String variables are immutable. You can’t do anything to change the values or properties held in a specific string, they are absolutely static. You can try adding properties to them, but they won’t stick.
    They do however have their own properties like .length, and methods like .indexOf, .repeat, .slice, .trim, etc.

  1. What are rest parameters?
  • Rest parameters are a clever way to let a function accept any number of arguments it is given. To create a function like this, you put a three dot -notation before the function’s last parameter. We can use the math.max function as an example, as math.max returns the biggest number of all the numbers it is given. See example below on how to write such a function:
function max(...numbers)
	let result = -Infinity;
	for (let number of numbers) {
		if (number > result) result = number;
	}
	return result;
}
console.log(max(4, 1 , 9, -1));
// 9

/* note: you don't actually have to fully understand the code 
within this code block to "get the point" with the rest parameter. */ 
  • When a function like this is called, the rest parameter gets bound to an array that contains all further arguments. The array then gets “spread out” in the function call and the arguments contained within, gets passed as separate arguments.

  • You can also call a function function with an array of arguments in this way, which very useful and important to know. Like this:

let numbers [5, 1, 7];
console.log(max(...numbers));
// 7

  1. (Feel free to skip the sub-chapter of Math object and Destructing)
  • I skipped Destructuring, but The Math Object felt important and i think it overall helped me to understand objects further. Specifically how JavaScripts math related functions are tucked inside the math object so that those bindings are safe and wont be overwritten as well as not “polluting” the namespace, allowing the use of those specific names as binding names when writing our own functions. It’s useful to read to really understand the grab-bag concept of objects. At least it felt helpful for me to better grasp objects as a whole.

  1. What is serialisation and what is a use case of serialisation of data?
  • Serialization of data means that we convert all the data stored within our objects, bindings, values, etc. to a flat description that can be saved and stored in a file for later access, or sent to another computer. This is a necessity since properties only grasp values, rather than contain it. Objects are stored in the computers memory as sequenses of bits holding the adresses - the place in the memory - of their contents. So serializing the data to a flat description is essential, or else if you would want to send the data, you’d kind of have to send your whole machine. Serialization is bacally way of converting a big tangle of memory adresses to a flat description that can be read and used later on. No matter on what computer or where it is accessed.

  1. What is JSON?
  • JSON (pronounced “Jason”) stands for JavaScript Object Notation. It is a popular serialization format, and it is widely used as a data storage and communication format on the web, even in languages other than JavaScript

  1. What are the differences between JSON and the way programmers write objects in plain Javascript?
  • JSON looks very similar to JavaScript in this, but there are a few differences.
  • All property names have to be surrounded by double quotes.
  • Comments are not allowed in JSON.
  • Only simple data expressions are allowed - (no function calls, bindings, or anyting that involves any actual computation.)

If i got anything wrong, feel free to correct me! I spent way to much time on this assignment to be okay with getting it all wrong. I'd appreciate your feedback!

1 Like

Great answers sir, you explained quite well and detailed all the questions, please keep them like that! :muscle:

Carlos Z

1 Like
  1. Storing different types of values is not possible in variables. Variables can only hold int or string values.

  2. Arrays can store multiple types of values.

  3. Values have properties that give some characterisitcs such as .length

  4. null and undefined values do not have properties.

  5. tow ways to access properties:
    value.x
    value[x]

  6. methods are properties that contain functions e.g. toUpperCase(), toLowerCase().

  7. Objects are data structures that have arbitrary properties inputed by the programmer.

  8. In an object we can now store any combination of values and call upon them like a property using for e.g objectname.property. Therefore we can stroe the weresquirrel’s activities in a object.

  9. An object is a data set where properties are seperated by colons from corresponding values.

  10. Objects are mutable and can be changed whilst string, intergers and booleans can not be changed.

Part 2:

  1. Because string values are immutable.

  2. Rest parameters are denoted by “…” and allow a function to accept an unlimited number of parameters.

  3. Serialisation converts data to a flat description. This is good for saving data and sending data to another computer.

  4. JSON stands for Javascript object notation and is widly used as a data storage and communication format on the web, even in languages other than JS

  5. The difference is all property names have to be double quoted and only simple data expressions are allowed ( No function calls, binding or anything that requires computing)

1 Like
  1. The problem is sorting multiple groups of data sets and the specific handling of that data.
  2. Arrays can be used to solve the problem of multiple values.
  3. Properties are like keys to values in used within an expression.
  4. Null and undefined do not have properties.
  5. “The two main ways to access properties in JavaScript are with a dot and with
    square brackets.” - Eloquent JavaScript
  6. Methods are properties that contain a function pertaining to a specific value(s).
  7. Objects are a value type that have “arbitrary collections of properties…” - Eloquent JavaScript.
  8. Objects help contain any and all data.
  9. Objects are a value type contained in braces.
  10. Mutability of objects means they can be changed later.

PART 2

  1. You cannot add new properties to String variables because they are immutable.
  2. Some functions contain many arguments “…the rest parameter is bound to an array containing all further arguments.” - Eloquent JavaScript.
  3. Fine with me.
  4. Serialization is the process of translating a data structure or object state into a format that can be stored or transmitted and reconstructed later.
  5. JSON = JavaScrip Object Notation
  6. " 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." - Eloquent JavaScript.
1 Like

Here are the answers to the first set of questions that I have read in chapter 4 of the Eloquent Javascript book and further research done online.

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 Jaques case he needs to save several different values to find the cause of his condition under the same variable.

  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 “description” of different values. They are expressions that access a property of a value.

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

  5. How can we access properties in a value (two ways)?
    = dot or square brackets

  6. What are methods?
    = A javascript method is an action that can be performed on the objects.

  7. What are objects?
    = Objects are a collection of data (properties and values) bound to a specific variable.

  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)?
    = an object can contain several datatypes.

  9. How do you define an object?
    = var user = { fname: “john”, lname: “doe”, age: 38, hobbies: [“gaming”, “running”, “wine”};

  10. What can you say about the mutability of Javascript objects?
    = it is possible to change the values in a javascript object.

SECOND PART:

  1. Why can’t you add new properties to a string variable?
    = They are immutable

  2. What are rest parameters?
    = Rest parameters represent any number of arguments in an array.

  3. What is serialisation and what is a use case of serialisation of data?
    = Serialisation is the conversion of data into a flat description, which is useful for saving and sending data.

  4. What is JSON?
    = Javascript object notation, it is used for data storage and communication

  5. What are the differences between JSON and the way programmers write objects in plain Javascript?
    = property names in json have to be in double quotes. json can not store functions or computations peforming expressions

2 Likes