Data Structures (Arrays and Objects) - Reading Assignment

PART ONE

1. Read the sub-chapter called The weresquirrel. What problems does this chapter introduce that cannot be solved with variable types such as strings or integers?
Variable types like strings and integers are only able to handle a single types of data. What Jacques needs is a data structure like an array to store multiple types of values and datatypes to keep track of all the information and keep it organized.

2. What variable type can be used in order to solve the problem of storing multiple values?
Arrays are a variable type that can store multiple types of values.

3. What are properties in Javascript?
Properties are ways to get types of meta-information from objects.

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

5. How can we access properties in a value (two ways)?
You can use the . notation such as myString.length or square brackets myString[“length”]

6. What are methods?
Methods are functions that belong to the object that allow us to do something to the data inside the object.

7. What are objects?
Objects are data structures that can contain an arbitrary collection of properties. These are created by using braces to contain a list of key values separated by commas.

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 great because they can hold anything including other arrays.

9. How do you define an object?
Objects are defined as any other variable, with the value being a list contained within braces.

10. What can you say about the mutability of Javascript objects?
Values in and object can be changed. Unlike other datatypes like strings can not be changed. It will always keep the same value that it was originally assigned

  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?
    Sometimes sequences of values need to be stored instead of just one long string. Data is stored as a list representation referred to as an array.
  2. What variable type can be used in order to solve the problem of storing multiple values?
    The variable type is referred to as an array.
  3. What are properties in Javascript?
    Properties are constants and functions of an object. A JavaScript object is a collection of unordered list properties.
  4. Which values do not have properties?
    The null value and the undefined value do not have properties.
  5. How can we access properties in a value (two ways)?
    Properties can be accessed by:
    a) Using the literal name of the property, for example, text.color.
    b) Using the index of the value, for example, text[0].
    The examples use in the book were array.length and array[“length”].
  6. What are methods?
    Methods are functions that are associated to an object. Every string, for example, has a toLowerCase function. These are referred to as methods of the value they belong to.
    The push() and pop() methods of an array add and remove values, respectively.
  7. What are objects?
    Objects are made up of an unordered (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 allow values to be grouped together.
  9. How do you define an object?
    Inside braces with a list of properties separated by commas. There is a colon after each property name.

var person[{ name:”Sam”,age:22},{name:”Jan”,age:21},{name:”Kim”,age:20}];

  1. What can you say about the mutability of Javascript objects?
    Objects work differently than other value types such as numbers, strings, and Booleans. Objects are not immutable which means that the value can be changed. Const type cannot be changed even if it is pointing to an object. In a Cont type a property is not allowed to be changed.

SECOND PART:

  1. Why can’t you add new properties to a string variable?
    A string is not an object and is immutable. That means that the string variable cannot be changed but the string variable does have built-in functions such as string.slice and string.indexOf.
  2. What are rest parameters?
    A rest parameter is bound to an array and its notation includes three proceeding dots.
  3. (Feel free to skip the sub-chapter of Math object and Destructing)
  4. What is serialization and what is a use case of serialization of data?
    Serializing the data is to convert the array data held in memory into a flat description.
    This is useful if you want to save the data to a file or send it somewhere else.
  5. What is JSON?
    JSON is a serialization format, which stands for JavaScript Object Notation. It is widely used as a method to store data and as a communication format.
  6. What are the differences between JSON and the way programmers write objects in plain Javascript?
    In JSON, all properties have to be surrounded by double quotes including the property names. No function calls are allowed and neither are comments.
    JavaScript provides the JSON.stringify and JSON.parse functions to convert data to and from the JSON format.

PART 2

1. Why can’t you add new properties to a string variable?
A string is not an object. So it is immutable

2. What are rest parameters?
** (Feel free to skip the sub-chapter of Math object and Destructing)**
It allows us to represent any number of argument into 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?
It is widely used as a data storage and communication format on the Web, even in languages other than JavaScript.

5. What are the differences between JSON and the way programmers write objects in plain Javascript?
Similar to arrays and objects noted in JavaScript, in JSON the properties are surrounded by double quotes but unlike in JavaScript, only simple data expression is allowed. This means no function calls, bindings, and comments are allowed.

1 More than one piece of data is required to be stored.
2 Array
3 Values separate data. There are six basic types of values: Numbers, strings, booleans, objects, functions, and undefined values.
4 undefined, null,
5 by using a dot or [].
6 Properties that contain a function.
7 A collection of properties.
8 Objects can hold many different data types.
9 {}
10 It is impossible to change values such as numbers, strings and booleans.

First

  1. Avariable that can store multiple values

2.Arrays

4.null and undefined

  1. . & []

  2. properties that hold function values

  3. Structures that can hold arbitrary colection of properties

  4. They can hold as many datatypes as wanted/needed

  5. {} separated by ,

  6. objects are mutable, strings, numbers and booleans are immutable

Second

  1. They are immutable

  2. Arrays and objects as bits holding adresses

  3. Standard for serialising objects

  4. JSOn only allows simple expressions.

FIRST PART:

  1. Problem is that we may want to store multiple strings or integers and we cannot do that with simple variable types (int, string).
  2. Arrays
  3. Properties help us get more information about a certain value.
  4. Null values.
  5. With a dot or with a square brackets.
  6. Properties that contain functions are called methods of the value they belong to.
  7. Objects are data structures that contain properties.
  8. Objects can contain different data types.
  9. Using {} braces as expression. Inside the braces properties are separated by commas. Each
    property has a name followed by a colon and a value.
  10. It means that properties in an object can be changed by making a second object with the same reference to the original one. Then if we change properties in one they are going to be changed to a same value in the other too.

SECOND PART:

  1. Strings are not objects and they are immutable.
  2. Rest parameters allow us to represent any number of arguments as an array.
  3. Converting tangles of memory addresses to a description that can be stored or sent. Data is converted into a flat description.
  4. 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. 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?
since integers and strings can store only one variable, it will be a problem to create 1 variable daily to store that data, in this cases a data structure to store multiple values is a more efficient way to solve this.

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

3. What are properties in Javascript?
Expressions that can access a property of a value, for example in arrays, to know how many elements it have, we can use array.length in order to get the total amount of elements.

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?
Properties that contain functions, in arrays for example: “array.push[something]” will add a new element to an array.

7. What are objects?
A data structure that cointains a collection of properties.
8. What problem do objects solve that cannot be solved with other value types we’ve learned so far (such as integer, string, array, boolean etc)?
It can contain multiple variable types, all variables mentioned on this question, can be stored on 1 object.

9. How do you define an object?

let object = {
booleanVar = true,
stringVar = “im an string”,
arrayVar = [“Im”, “an”, “Array”],
integerVar = 1
};

10. What can you say about the mutability of Javascript objects?
mutability is the action that allows an object element to be change or modified after his declaration.

numbers, strings, and Booleans, are all immutable

meaning that you cant change the variable type, but for example, if an object have a boolean started at false, in the code process this object element can be switch to false if need it for example, has mutated.

SECOND PART:

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

2. What are rest parameters?
It allows us to pass a lot of elements has arguments into an array.

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?
Its the conversion of data into a flar description, wich will be used to spread over the network in a simple format.

5. What is JSON?
JavaScript Object Notation, an standard text format to share data.

6. What are the differences between JSON and the way programmers write objects in plain Javascript?
JSON is used to share data has a plain text format, while Javascript its a programming language.

2 Likes

Read the sub-chapter called The weresquirrel. What problems does this chapter introduce that 1.cannot be solved with variable types such as strings or integers?
How to store several types of data in one 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?
the value associated with the JS object: myStringLeght ; mathMAx ;
4.Which values do not have properties?
null,endifined
5.How can we access properties in a value (two ways)?

  1. value.x (fetch the property of value named X ) value.leght
  2. VALUE [X] evaluate the expression X and uses the result as the property name
    6.What are methods?
    Methods are properties that refer to function value :join() ;push();map();indexOf()
    7.What are objects?
    Objects allow us to group value - including other objects together .
    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)?
    build more complex structures of data
    9.How do you define an object?
    let obj = {
    cars: false,
    engine: [“diesel”, “gasoline”, “hybrid”, “electrical”]
    };
    10.What can you say about the mutability of Javascript objects?
    Objects are mutable.You can have two different objects with same properties,two references to one object
    SECOND PART:
    1.Why can’t you add new properties to a string variable?
    Value of types:string,number and boolean are not objects.The value are imutable and can’t be change.Cannot add or delete their properties(They are buld-in)
    2.What are rest parameters?
    Function to accept any number of arguments(…).When such a function is called, the rest parameter is bound to an array.
    let numbers = [5, 1, 7];
    console.log(max(…numbers));
    // → 7
    containing all further arguments.
    3.What is serialisation and what is a use case of serialisation of data?
    Serialize the data-converted into a flat description .Json alow us to convert from string to value.
    4.What is JSON?
    JavaScript gives us the functions JSON.stringify and JSON.parse to convert
    data to and from this format. The first takes a JavaScript value and returns
    a JSON-encoded string. The second takes such a string and converts it to the
    value it encodes

5.What are the differences between JSON and the way programmers write objects in plain Javascript?
require duble qoute “”

1 Like
  1. We need multiple values and data types. Strings and integers don’t
    offer a solution.
  2. Arrays and objects
  3. Properties are expressions that access values
    myString.length
    Math.max
  4. null and undefined
  5. We can access properties in a value with a dot or with a square
    brackets
  6. Properties that contain functions are methods,
    push method, pop method
  7. Arbitrary collection of properties are values of the type object, using
    braces
  8. You can store different types of data
  9. A list of properties inside braces, separated b commas. Each
    property has a name followed by a colon and value
  10. You can change their properties, single object value could have
    different content at different times

SECOND PART:

  1. Values of type string, number and boolean are not objects. They
    have build in properties and can not be changed.
  2. Rest parameters accept any number of arguments
    function max (…numbers) { }
    let numbers = [5,1,7];
  3. Serialization is when data is converted into a flat description to save
    for later or send it
  4. JSON is a popular serialization format widely used as a data storage
    and communication format on the Web
  5. In JSON: - all property names are represented by " "
    - only simple data expressions
    - no function calls, binding or computations
    - comments are not allowed
1 Like

1 A data structure is required that can store mulitole values.
2 Array
3 Properties are assigned to a value
4 null, undefined
5 dot notation and square brackets
6 Functions that contain functions and belong to the value they belong to.
7 A collection of properties contained within curly braces.
8 Objects can contain many different value types.
10 Object values can be modified

1 A string is a primitive and immutable.
2 A rest parameter allows a function to accept multiple arguments
3 Serialisation flattens data to make access and sending more efficient.
4 JS object notation is a method of seialisation.
5 All property names have to be surrounded by double quotes,
and only simple data expressions are allowed—no function calls, bindings, or
anything

1 Like
  1. Storing multiple data in 1 variable.

  2. Array

  3. Properties are the values associated with a JavaScript object . For example, All cars have the same properties , but the property values differ from car to car.

  4. Null, undefined

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

  6. JavaScript methods are actions that can be performed on objects. For example, all cars have the same methods, but the methods are performed at different times.

  7. Objects are variables which can contain many values.

  8. Mutability and holding multiple different datatypes.

  9. Ideally, we would like to group these
    together into a single value and then put those grouped values into an array of
    log entries.

  10. They are mutable, where strings, integers and booleans aren’t.

1 Like
  1. The value of a string always remains the same.

  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.

  3. READ.

  4. Converting data into a flat description. If you want to save data in a file for later or send it to another computer over the network, you have to somehow convert these tangles of memory addresses
    to a description that can be stored or sent. You could send over your entire
    computer memory along with the address of the value you’re interested in, I
    suppose, but that doesn’t seem like the best approach.
    What we can do is serialize the data.

  5. A popular serialization format is called JSON (pronounced
    “Jason”), which stands for JavaScript Object Notation. It is widely used as a
    data storage and communication format on the Web, even in languages other
    than JavaScript. JSON looks similar to JavaScript’s way of writing arrays and objects, with a
    few restrictions.

  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.

1 Like

a. First Group of Questions:

i.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? Variables types such as strings or integers
do not have and cannot have other properties which can describe an item or object.

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

iii.What are properties in Javascript? A JavaScript property is a characteristic of an object, often describing attributes associated with a data structure. There are two kinds of properties: Instance properties hold data that are specific to a given object instance. Static properties hold data that are shared among all object instances.

iv.Which values do not have properties? The null and undefined values.

v.How can we access properties in a value (two ways)? By a .name to fetch the property or by [x] to fetch the property by text.

vi.What are methods? JavaScript methods are actions that can be performed on objects. A JavaScript method is a property containing a function definition.
vii.What are objects? An object is a collection of properties, and a property is an association between a name (or key) and a value. An object is complex structure.

viii.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 contains many properties, all grouped together with a common name.

ix.How do you define an object? A variable that has several properties. Its values are contained within braces.

x.What can you say about the mutability of Javascript objects? Numbers, Booleans and strings are immutable objects – their values cannot be changed.

b.Second Group of Questions:

i.Why can’t you add new properties to a string variable? A string variable is an ‘atom’ or primitive type structure, that data structures (objects) are built upon.

ii.What are rest parameters? The ‘rest’ parameter is an improved way to handle function parameter, allowing the capability to 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. The rest parameter has 3 dots before its name.

iii.What is serialisation and what is a use case of serialisation of data? Serialization is the converting the contents of memory into a flat description. A use case for serialization is to save data in a file for later use or to send the data to another computer.

iv.What is JSON? JavaScript Object Notation. The data storage and serialization format is used to transfer data from one program or computer to another.

v.What are the differences between JSON and the way programmers write objects in plain Javascript?. JSON contains no function calls, bindings or computations. Other differences is that in JSON all property names have double quotes and only simple data expressions are allowed.

1 Like

PART I

1… store a sequence (collection) of values
2. the ARRAY - written as a list of values between square brackets, separated by commas.
The values stored in an array are known as the ELEMENTS of the array.
3. ELEMENTS in an ARRAY are stored as the array’s PROPERTIES, using numbers as property names.
4. null and undefined
5. a dot or with square brackets:
value.x - Using a dot, the word after the dot IS THE LITERAL NAME of the property
value[x] - Using square brackets, the expression between the brackets IS EVALUATED TO GET the property NAME
6. PROPERTIES that contain FUNCTIONS are generally called METHODS.
7. AN ARRAY OF ARRAY’S. Values of the type object are arbitrary collections of properties
8. Grouping together of arrays.
9. use braces as an expression
- inside braces, list properties separated by commas
- each property has a name followed by a colon and a value
- objects written over multiple lines use indenting to help with readability
- Property invalid binding names or invalid numbers have to be quoted
10. object values can be modified, types of values such as numbers, strings, and Booleans, are all immutable

PART II

  1. such values are immutable and cannot be changed.
  2. a function that accepts any number of arguments
  3. serialize the data. That means it is converted into a flat description. A popular serialization format is called JSON
  4. JavaScript gives us the functions JSON.STRINGIFY and JSON.PARSE to convert data to and from this format.
    The first takes a JavaScript value and returns a JSON-encoded string.
    The second takes such a string and converts it to the value it encodes.
  5. All property names have to be surrounded by double quotes, and only simple data expressions are allowed—no function calls,
    bindings, or anything that involves actual computation. Comments are not allowed in JSON.
1 Like
  1. Read the sub-chapter called The weresquirrel. What problems does this chapter introduce that cannot be solved with variable types such as strings or integers?

irregular occurances, triggering conditions, multiple conditions, unknown variables

  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 are expression that access a property of some value. Examples of properties are myString and Math.max

  1. Which values do not have properties?

Null and undefined

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

A dot and square brackets

  1. What are methods?

Properties that contain functions are general called methods of the value they belong to. toUpperCase is a method of string.

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


Here is where I learned a valuable lesson: Read all of the instructions before starting on the chapter. I read all of the weresquirrel higher math sections and was about ready to give up! Next time, I will read all of the instructions so I will know which parts to skip and which parts to pay attention to!


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

A string is not an object but a primitive type, so they are immutable.

2.What are rest parameters?

The rest parameter syntax allows us to represent an indefinite number of arguments as an array.

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

Serialization of date means that it is converted into a flat description. 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.

  1. What is JSON?

JSON stands for JavaScript Object Notation. 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?

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. It requires a variable that can store multiple values.
  2. Arrays and Objects
  3. Most Javascript values have properties. Such as the length of an array or the index of a value
  4. null and undefined
  5. value.x // value[x]
  6. Methods are properties that hold function values. These are special kinds of functions that only work on the value they belong to.
  7. A collections of properties, inside object the user can store different value types.
  8. Object can store values of different types as integers, booleans, strings and arrays.
  9. e.g. “var ball = {color: “red”, size = 10}”
  10. The values they contained can be changed.

Second Part:

  1. Because string variables are immutable
  2. It is the use of any number of arguments in a function.
  3. Skipped
  4. 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.
  5. JavaScript Object Notation is a serialisation format widely used for data storage and communication.
  6. All property names need to be surrounded in double quotes and only simple data expressions are allowed. So no function calls, bindings, or anything that involves actual computation. Also, comments are not allowed in JSON.
1 Like
  1. Read the sub-chapter called The weresquirrel. What problems does this chapter introduce that cannot be solved with variable types such as strings or integers? It requires the organised storage of groups of related data sets.

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

  3. What are properties in Javascript? Properties are the values associated with a JavaScript object.

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

  5. How can we access properties in a value (two ways)? By using dot notation or bracket notation.

  6. What are methods? Methods are functions that are stored as object properties.

  7. What are objects? Objects are collections of organised data relating to itself.

  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 can store collections of mixed data types (like arrays within arrays).

  9. How do you define an object? Here is an object (thePhone), with the properties, or ‘keys’, of apps, txts, and isAndroid. Each key has several values:
    let thePhone = { apps: [ “linkedin”,“facebook”,“camera” ], txts: [ “wifey”,“george”,“garage” ], isAndroid: true };

  10. What can you say about the mutability of Javascript objects? Objects are mutable as the values can be altered.

SECOND PART:

  1. Why can’t you add new properties to a string variable? Because they are immutable and cannot be changed.

  2. What are rest parameters? A rest parameter can be called using the three dots operator (…) before the arrays name. It will then call ALL values stored in the array as single arguments, or entities.

  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? It is a way to package data (memory addresses) ready for storing or moving to another location. ie. to send it over the net.

  5. What is JSON? It is JavaScript Object Notation.

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

1 Like

Hi, looks like the answer to the last question is missing? :slightly_smiling_face:
Ivo

Hi, and oops! :crazy_face:

Thanks and here it is:

  1. What are the differences between JSON and the way programmers write objects in plain Javascript? JSON does not accept comments, property names must be encapsulated in double quotes, and you cant include any function or calls or bindings. ie. only simple data expressions.
2 Likes