Data Structures (Arrays and Objects) - Reading Assignment

  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 introduced in this chapter is that each tracking entry needs to store a list of activities, and to determine a true or false answer. With strings you run into problems accessing the data. With Arrays you can easily access individual pieces of data.

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

An [Array] is used to store multiple values.

  1. What are properties in Javascript?

Properties describe the values such as the length, the minimum, maximum, etc.

  1. Which values do not have properties?

null and undefined do not have properties.

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

You access properties with a dot and with [ ], they access a property value, but not necessarily the same property.

  1. What are methods?

Methods are basically properties that hold function values.

  1. What are objects?

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

Objects allow you to store and access information in a data set.

  1. How do you define an object?

An object is a list of properties set within {} and separated by commas. The property name is followed by a colon and the value.

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

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

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

String variables are immutable and cannot be changed. There are built in properties which resemble the array method such as:
• .slice, .trim, . indexOf, .split, .repeat.

  1. What are rest parameters?

The rest parameters will hold are arguments, which can then be included in other arguments.

  1. Skipped…

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

Serialization is when data is converted into a flat description.

  1. What is JSON?

JSON is a way to store and communicate info on the Web.

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

Property names have to be surrounded by double quotes and only simple data expressions are allowed (no functions, bindings or anything involving computation).

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

Prior to this chapter, we were dealing with simple programs that only dealt with small amounts of data. In weresquirrel, a large and more complex data structure is need to store the large amounts of information in a journal.

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

In JavaScript we can use a data type called array that is specifically for storing and working with sequences of values.

  1. What are properties in Javascript?

Properties are expressions that access a property of some value. eg/ myString.length where the property “length”, gives you the length of a string.

  1. Which values do not have properties?

The values null and undefined will give you an error if you try to access a property from it.

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

Properties can be accessed from a value with either a dot, denoted as value.x, or with square brackets, which is denoted as value[x]. The x in both these examples however is interpreted differently. When using a dot, x = literal name of property and only works with names that look like valid binding names eg/ value.color will give you the color property. When using square brackets, x is evaluated to get the property name eg/ value[“John Doe”] will give you access to a property named John Doe.

  1. What are methods?

Methods are functions that live in properties and (usually) act on the value they are a property of.

  1. What are objects?

Objects allow us to group values - including other objects - together and thus build more complex structures.

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

Unlike other value types, objects are best for representing “things” with characteristics aka properties. It can store functions, arrays, regular expressions and even objects. Objects are also mutable unlike other value types, allowing you to change their properties.

  1. How do you define an object?

An object is defined by using braces as an expression. In the braces properties are separated by commas. As for the properties, it’s a name followed by a colon and a value. Properties must be in quotation marks if they aren’t valid binding names or valid numbers. If you try to access a property that doesn’t exist you will get undefined.

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

Objects in Javascript are a mutable value unlike many others. It allows you to change the properties of an object, causing a single object value to have different content at different times.

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?

Values of type string, numbers or booleans are immutable and cannot be changed, added to, or deleted. They have built in properties.

  1. What are rest parameters?

The rest parameter syntax allows a function to accept an indefinite number of arguments as an array, providing a way to represent variadic functions in JavaScript.

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

Serialisation is the act of converting tangles of memory addresses into a flat description that can be stored or sent. A popular serialisation format is called JSON and is widely used as a data storage and communication format on the Web.

  1. What is JSON?

JSON stands for JavaScript Object Notation and is a popular serialisation format used for storing and sending information on the Web.

  1. 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 also not allowed in JSONt.

1 Like

1:
We need to be able to store multiple values and data types within a variable. --> Data structure.

2:
Arrays

3:
A characteristic of the values in a specific data structure.
Example =>
var str = ‘Hello’
str.length
// 5
This property accesses the length value of my string datatype.

4:
null and undefined

5:
Using the dot notation by writing the literal name of the property after the name of your data structure, or by
using square brackets [] in which the expression between the brackets will be evaluated to get the name of that property.

6:

Methods are properties that contain functions to the value they belong to.
Example:
toUpperCase is a method of a string.

7:
Objects are arbitrary collections of properties.

8:
Objects give you the ability to store a log of all sorts of data(types) and a boolean expression for example to go with it.
It is even more elaborate than an array.

9:
With the curly braces {}
Example:
berryFruits = {

berry: true,
fruits: [‘banana’, ‘cranberry’, ‘blueberry’, ‘bilberry’]
};

10:
The values of objects in JavaScript have the ability to be changed, unlike data types such as string, integer, and Boolean values.

PART 2:

1:
Those values are immutable, and therefore can’t be changed. You can try to assign new properties to them if you please
(no error will come from doing so), JavaScript doesn’t actually store those properties and they will return undefined

2:
Not sure on this one, but I think a rest parameter holds an array containing all further arguments of a function
with limitless arguments. These functions are created by using a triple dot notation ‘…’

3:
Serializing data means converting it to flat description. This is often done in a format called JSON (JavaScript Object Notation).
It is used as a data storage and communication format on the web. (This goes beyond JavaScript).

4:
JavaScript Object Notation. Making it possible to easily serialize data.

5:
JSON is identical to JavaScript in the way it codes objects and arrays, but it is much more restrictive.
Property names have to be surrounded by double quotes, it doesn’t allow function calls, bindings, or anything
that involves actual computation. It only allows simple data expressions. (comments are also 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?
    A data structure in this case because they are capable of storing multiple values and datatypes.
    Array. The most basic of all data structures, an array stores data in memory for later use.

  2. What variable type can be used in order to solve the problem of storing multiple values?
    It is called an array and is written as a list of values between square brackets, separated by commas.

  3. What are properties in Javascript?
    Almost all JavaScript values have properties.
    JavaScript objects have two types of properties: data properties and accessor properties.

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

  5. How can we access properties in a value (two ways)?
    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?
    The push method adds values to the end of an array, and the pop method does the opposite, removing the last value in the array and returning it.

  7. What are objects?
    Values of the type object 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)?
    Objects can store sequences of things and integer, string, array, boolean can only store one value a the time.

  9. How do you define an object?
    Objects work differently. You can change their properties, causing a single object value to have different content at different times.

  10. What can you say about the mutability of Javascript objects?
    Mutable is a type of variable that can be changed. In JavaScript, only objects and arrays are mutable, not primitive values.


    SECOND PART:

  11. Why can’t you add new properties to a string variable?
    String, number, and Booleans are immutable and cannot be changed.

  12. What are rest parameters?
    It can be useful for a function to accept any number of arguments.
    The rest parameter allows a function to accept an indefinite number of arguments as an array.

  13. What is serialisation and what is a use case of serialisation of data?
    The process whereby an object or data structure is translated into a format suitable for transferral over a network, or storage (e.g. in an array buffer or file format).

  14. What is JSON?
    JSON stands for JavaScript Object Notation
    It is widely used as a data storage and communication format on the Web

  15. What are the differences between JSON and the way programmers write objects in plain Javascript?
    All property names have to be surrounded by double quotes, and only simple data expressions are allowed—no function calls, bindings, or anything that involves actual computation. Comments are not allowed in JSON.

1 Like

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 we need to record a series of activities for a day, and whether this has any relationship with transforming to a squirrel or not. The activities we want to record are neither strings nor integers, but something else.

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

We can use an array

What are properties in Javascript?

It is a characteristic of an object- describing attributes associated with a data structure.

Which values do not have properties?

Null and undefined do not have properties.

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

We can access properties with a dot and square brackets.

Dot: the word after the dot is the literal name of the property.

Brackets: the expression between the brackets is evaluated to get the property name.

What are methods?

Methods are properties that contain functions.

What are objects?

Objects are collections of properties.

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

An object allows you to assign values to keys, it is like being able to make arrays of arrays.

How do you define an object?

An object is defined using braces, or otherwise using Object().

What can you say about the mutability of Javascript objects?

Objects are mutable. This means that you can change the properties of objects, causing a single object value to have different content at different times.

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

You can´t add new properties because strings (also numbers and Booleans) are immutable.

What are rest parameters?

THey are indefinite number of arguments , as an array that can be used in some functions.

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

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

Serialization: the process whereby an object or data structure is translated into a format suitabole for transferal over a network or storage.

We convert the data into a flat description.

What is JSON?

It is a serialization format. JavaScript Object Notation.

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

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

1 Like
  1. Read the sub-chapter called The weresquirrel. What problems does this chapter introduce that cannot be solved with variable types such as strings or integers?
    To be able to store more than a single type of data.

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

  3. What are properties in Javascript?
    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?
    Null and undefined

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

  6. What are methods?
    A property that holds function values

  7. What are objects?
    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)?
    They can hold as many different data types as we need

  9. How do you define an object?
    Using braces as an expression

  10. What can you say about the mutability of Javascript objects?
    You can change the variable’s value at any time
    SECOND PART:

  11. Why can’t you add new properties to a string variable?
    String variables are immutable

  12. What are rest parameters?
    For functions that accept any number of arguments

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

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

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

  16. What are the differences between JSON and the way programmers write objects in plain Javascript?
    All properties have to be surrounded in double quotes

1 Like
  1. Read the sub-chapter called The weresquirrel. What problems does this chapter introduce that cannot be solved with variable types such as strings or integers?
  • A variable has to have a collection of information instead of a single string or integer represented in a variable.
  1. What variable type can be used in order to solve the problem of storing multiple values?
  • Arrays
  1. What are properties in Javascript?
  • The characteristic of the element or value
  1. Which values do not have properties?
  • null and undefined
  1. How can we access properties in a value (two ways)?
  • value.x or value[x]
  1. What are methods?
  • Properties that contain functions
  1. What are objects?
  • Objects are values with a collection 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)?
  • Objects allow you to store different property for each element
  1. How do you define an object?
  • By using braces as an expression
  1. What can you say about the mutability of Javascript objects?
  • Values such as such as numbers, strings, and Booleans, are all immutable however object are mutable as in their properties can be changed causing a single object value to have different content at different times

SECOND PART:

  1. Why can’t you add new properties to a string variable?
  • They are immutable
  1. What are rest parameters?
  • Rest parameters are functions that can accept any number of arguments
  1. (Feel free to skip the sub-chapter of Math object and Destructing)
  • Skipped
  1. What is serialisation and what is a use case of serialisation of data?
  • Serialization means to convert data into a flat description that can be stored or sent
  1. What is JSON?
  • JSON stands for JavaScript Object Notation and is often 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?
  • 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

Part 1:

  1. Strings and integers can only store single values, in this chapter we need variables that can store a sequence of data like an array.

  2. Arrays.

  3. Properties are the characteristics of a variable or value.

  4. Null and undefined values do not have properties.

  5. with a . or with [ ]

  6. Methods are properties that contain functions.

  7. Objects are a collection of values with properties.

  8. Objects allow you to store multiple values of different data types.

  9. Objects ca be defined using the { } as an expression.

  10. Objects are mutable since their properties can be changed causing a single object value to have different content at different times.

Part 2:

  1. Unlike objects, strings are immutable.

  2. A function that can accept any number of arguments.

  3. Serialization is when you convert data into a flat description that can be stored or transferred. JSON is one of the most popular serialization formats.

  4. JSON stands for JavaScript Object Notation. It is a popular serialization format for data storage and communication across the web.

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

1 Like
  1. it needs multiple values
  2. arrays.
  3. they access a property of a value
  4. Null and undefined
  5. value.x and value[x]
  6. properties that contain functions are generally called methods.
    7.arbitrary collections of preperties.
  7. they can store values of different types.
  8. braces are used to define an object
  9. mutability means that the values can be changed.

second part
1.they are immutable
2. use of any number in a function.
3.
4.to flatten the description of the data
5.Javascript object notation. it is a popular serialisation format. used as a data storage and communication format on the web.
6. name need to be in quotes and only simple data allowed. and commments are not allowed in JSON

1 Like

1,since strings are only able to hold 1 value and the rodent want to keep multiple values stored in a datastructure…
2. arrays
3. definers of values… such as lemgth of a string or index of a value
4. null undefined
5 array [“length”]
array.length
6. functions that are "bound " only to a certain value by design are called methods
7. basicclally arrays=
8. manually decide value
9. just like any othe variable but to define you must define through brackets
10 values can be changed unlike strings which will always keep the value given to it

1 Like
  1. The main problem is that a data structure is required to store information correctly. Strings are not well suited for this requirement, as converting digits from within a string to numbers, and vice versa,1 is awkward.

  2. Arrays are the most appropriate variable type to be used for storing multiple values because they can be used to store sequences of values. Within an array its elements are stored as the arrays’ properties, using numbers as property names.

  3. Almost every Javascript value has properties. A property defines a form of characteristic about the values within a data structure. A primary example would be the length of an array or the index of a value.

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

  5. There are two main ways to access properties in a value.
    - by using a dot “.” with the literal name of the property. Example: array.length
    - by using square brackets “[ ]”, with the expression being placed between the brackets to be evaluated to get the property name. Example: array["length]

  6. Properties that contain functions are defined as the methods of the value they belong to.

  7. Objects are a type of value that have erratic collections of properties.

  8. Objects are special because they allow the storage of different datatypes together (integers, strings, booleans, arrays, etc)

  9. To create an object, you use braces { }. The properties within the braces are separated by commas, where each property is defined with a name followed by a colon and then a value.

  10. Objects differ from numbers, strings a booleans which are all immutable (unchangeable). Objects can have their properties changed or updated by the user or code. This means that within an object a single value can have different content at differing points in time.

  1. This is because strings are an immutable type of variable, and cannot be changed. Even if you try to set a new property to a string and Javascript doesn’t throw up an error, it will not store the new property you are trying to set. Only objects can have properties changed.

  2. Rest parameters are bound to an array which contains all further arguments given to a function. They accept any number of arguments. This is done by using three dots “…” before the functions final parameter.

  3. (Read anyway)

  4. Serialization is when data is converted into a flat description. Storing objects and arrays in such a format allows for the convenient storage and communication of the data over computers and networks.

  5. JSON is a popular format of serialization used widely on the web for Javascript and other languages. It stands for “Javascript Object Notation”.

  6. Despite the JSON writing format looking quite similar to Javascript, there are some key differences and restrictions. All property names in JSON must be surrounded by double quotes " ", only simple data expressions are accepted. Anything that involves actual computation is not allowed, as well as function calls, bindings and comments.

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

If you have a set of numbers, you can use strings to represent them, but its awkward. You would have to somehow extract the digits and convert them back to numbers to access them.

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

Arrays can be used to store multiple values.

  1. What are properties in Javascript?

Most JS values have properties, they define some characteristics about the values in a data structure; length if an array or index of a value.

  1. Which values do not have properties?

Null and undefined

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

Value.x

Or

Value[x]

  1. What are methods?

Methods are properties that contain functions.
“toUpperCase” is a method of a string
Sequence.push adds value to end of an array
Sequence.pop removes end value from an array

  1. What are objects?

Arbitrary collections of properties. One way to create an object is to use { }

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

Objects can hold many different data types and can be changed. They are very flexible.

  1. How do you define an object?

Objects are listed within { }

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

Numbers, strings, booleans are all immutable, its impossible to change the values of these types.
You can change the properties of objects, which causes a single object value to have different content at different times.

SECOND PART:

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

JS doesn’t store new properties to strings.

  1. What are rest parameters?

When a function is called, the rest parameter is bound to an array containing all further arguments.

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

To serialize data is to convert it to a flat description. This is useful if you want to save data in a file for later or send it to another computer over the network.

  1. What is JSON?

Javascript object notation. Its a popular serialization format. Its widely used as a data storage and communications format on the web, even in languages other than JS.

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

JSON looks very similar to JS’ way of writing arrays and objects, with a few restrictions. All property names have to be surrounded by “”. Only simple data expressions are allowed, no function calls, bindings or anything that involves actual computation. Comments aren’t allowed in JSON. Use function JSON.STRINGIFY and JSON PARSE to convert data to and from this format.

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?
When dealing with multiple elements where their values can be changeable, we need a way of storing more than one value at a time that can be easily modified. Strings and integers do not allow for this, as once created their values cannot be changed.

2. What variable type can be used in order to solve the problem of storing multiple values?
Arrays, which let us store a list of multiple elements in a single variable.

3. What are properties in Javascript?
Values that are associated with an object, such as an array.

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

5. How can we access properties in a value (two ways)?
Either with a dot or square bracket. We can use the dot notation when we know the name of the property, such as array.length, whereas square brackets will evaluate whatever’s inside the bracket in order to extract the property name; e.g. array[2] will extract the property name of the third element in an array.

6. What are methods?
Methods are properties that contain set functions, which can be rendered on objects.

7. What are objects?
Objects are variables that can consist of many properties, where values can be assigned to each of those properties; e.g. const wine = {grape:”Pinot Noir”, color:”Red”, tastingNotes:”Cherry”}.

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)?
While objects and arrays are both completely mutable, unlike strings and integers, we can’t change the rules of arrays, whereas objects allow that bit more flexibility in that functions can be applied. Ultimately this means that any data collected can be processed, and arbitrary information can be refined and utilised and presented in a more formulated manner.

9. How do you define an object?
By declaring a constant variable, such as the example given in question 7 above.

10. What can you say about the mutability of Javascript objects?
The mutability of JS objects means that their overall state can be modified once they’ve been created, unlike strings and numbers which are immutable.

SECOND PART:

1. Why can’t you add new properties to a string variable?
A string is an example of a primitive value, that unlike objects and arrays which are mutable, cannot be changed once created. The variable used to create the string can be appended to, though JavaScript will still need to refer to the original string that was defined when the variable was created.

2. What are rest parameters?
A special parameter that’s defined by three dots prior to the name of value, and enables a function to accept any number of arguments against that value. There can only be one rest parameter per function, and if you’re using more than one parameter, it needs to be the very last parameter. In the example function totalExpenses (flightCost, hotelBill, …sundryExpenses) , if seven arguments were entered, the last five would be assigned against sundry expenses.

3. N/A

4. What is serialisation and what is a use case of serialisation of data?
It’s the mechanism of converting a JavaScript object or data structure into a flat array (single string) or file format that can be shared with other applications and devices across a network, such as a client’s laptop and a network server.

5. What is JSON?
Standing for JavaScript Object Notation, JSON converts JavaScript objects into a text only format that can interface with other applications and devices to enable reliable data transfer and storage.

6. What are the differences between JSON and the way programmers write objects in plain Javascript?
JSON also use double quotes around property names, with only simple data expressions allowed, and functions can’t be called nor anything processed or computed. While JSON can be used standalone, it would require converting to a native JavaScript object in order to access the data.

1 Like