Data Structures (Arrays and Objects) - Reading Assignment


#123

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?

To begin with, string and integer variable types can only contain one value of data. For example when it comes to a string, you can only add a value ones to that specific variable and that’s it. Same goes for integer type of variables or char. What if you need a variable where you can put multiple data values, or keep adding values as the program goes on?

  1. What variable type can be used in order to solve the problem of storing multiple values?
    An Array variable. That’s the whole point with arrays, you can store multiple values in an array variable and add even more if you would need it. Its just like the name of the variable suggests, an array of values.
    You can even have two- or three-dimensional arrays if needed!

  2. What are properties in Javascript?
    Variables and values have properties in Javascript. A property would be, for example, to get the length of a string. To get the length of the string, you invoke it by its expression. so, you express the property that you would like to invoke.
    Example below:
    var text = “123abc”;
    console.log(text.length);
    The output will be 6 in the console.

  3. Which values do not have properties?
    All values in Javascript have properties except for ‘undefined’ and ‘null’.

  4. How can we access properties in a value (two ways)?
    We can do that with either dot (’.’) or square brackets. They don’t work in the same way and perform different tasks but depending on how you write the code and how the JS-machine interprets the ‘x’ value, you could invoke the same property with both ways, all though one way is always more efficent than the other depending on the property you want to access.

  5. What are methods?
    Methods are properties for a value that contains a function. Methods only work for specific function values, for example you could use the .toUpperCase method in a string text to return the text with all the letters capitalized. But you wouldn’t be able to use this method on an integer variable since there is nothing to capitalize.

  6. What are objects?
    Objects are values of arbitrary collections of values. See of it more like a grouping of data.

  7. What problem do objects solve that cannot be solved with other value types we’ve learned so far?
    With objects, we can store many different data types. The value types that we’ve learned so far can only store one type of data. Even arrays, once you’ve decided if your array variable is going to hold integer values or string value, you have to stick to it. You can’t declare an array with integer values and then add string values to a certain element in that array.

  8. How do you define an object?
    You define in just like an other variable, but you add its values inside curly brackets(braces).

  9. What can you say about the mutability of Javascript objects?
    The mutability of objects is just like it sounds, mutation of values in objects, meaning they change. Not that they do, but they can if you so will. Another way of putting it would be references. Two objects referr to one another. When one value changes, then so does the value in the other object aswell. As long as they are referred, they will have the same values, even after changing just one of the objects.

Second part

  1. Why can’t you add new properties to a string variable?
    Because it is not an object, but a primitive datatype. They are immutable.

  2. What are rest parameters?
    A rest parameter is bound on the array for further arguments. It contains all aditional arguments given to a function.

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

  4. What is serialisation and what is a use case of serialisation of data?
    Serialisation is when you convert the data that is stored in the memory into a flat description. This is useful for when we save the data to a file or if we want to transfer that data from one computer to another.

  5. What is JSON?
    JSON stands for Javascript Object Notation and it is a serialisation format that is widely used for storing data.

  6. What are the differences between JSON and the way programmers write objects in plain Javascript?
    JSON is familiar with Javascript’s way of writing but it has a few restrictions.
    All property names have be surrounded with double quotes and you can only use simple expressions, no calls or bindings, not even comments.


#124

FIRST PART

  1. When we need to handle many values or types of values an once, simple types as strings and integers can’t do that, only arrays and objects.
  2. Arrays and Objects
  3. Similar to the properties of fluids or any given object in the fisical world, properties are variables or definitions inside an object that can store values, like “Water.temperature = 100”
  4. “null” and “undefined”
  5. Like this => Water.temperature or like that => Water[“temperature”]
  6. They are “properties” that work as a function in a object, for instance => Water.heatOrCold(newTemperature) //raises or lowers the temperature
  7. An Object is a collection os properties
  8. Objects allow to work with different values and types inside the same scope, so it’s a more efficient way to define behaviors, similar to those from the fisical world
  9. let <object_name> = { <object_properties> }
  10. Mutability describes how two objects are different instances of each-other, even if they have the same properties. For instante, two twins can both be Human, and with the same properties like Human.height, Human.weight, etc., but they are still two different humans

SECOND PART:

  1. Strings are immutable
  2. They are ways to pass many parameters to a function (I admit I found it a bit confusing…)
  3. ok
  4. Serialization is a way to organize data for storage or communication via internet.
  5. JSON is a very common way to serialize data, based on JavaScript’s way of defining objects
  6. JSON can’t contain expressions that involve any kind of computation, neither comments, and all property names must be surrounded by “double quotes”.
    What are the differences between JSON and the way programmers write objects in pPreformatted text

#125

What problems does this chapter introduce that cannot be solved with variable types such as strings or integers?

Collecting and retrieving a collection of data or parts of the data.

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

Array.

What are properties in Javascript?

The elements in an array.

Which values do not have properties?

null and undefined.

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

with a dot and with square brackets. Bothvalue.x and value[x]

What are methods?

Properties that contain functions are generally called methods of the value they belong to,
as in “toUpperCase" is a method of a string”.

What are objects?

arbitrary collections of properties

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

Allows us to store a sequence or collection of data

How do you define an object?

using braces as an expression.

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

they are immutable

What are rest parameters?

… allows any number of auguments

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

That means it is converted into a flat description.
Usually to be exported or imported across a network.

What is JSON?

JavaScript Object Notation.

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.


#126
  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?
    Strings and integers can only hold single value and they are immutable values. What happened in the chapter was Jacque needed to figure out how, when and the cause. Therefore, what Jacque needs is a data structure which is capable of storing multiple values and data types. That’s why we need array in this case, it holds different multiple values, or collection of strings & integers.
  2. What variable type can be used in order to solve the problem of storing multiple values?
Array can store multiple data index position with string and integer.
Array are stored in [ ] , separated by commas.
let day1 = [ "Home" ];
console.log(day1);
// ["Home"]
day1.push("School");
day1.push("Park");
day1.push("Mall");
console.log(day1);
 (4) ["Home", "School", "Park", "Mall"]
  1. What are properties in Javascript?
    Properties are value associated with Javascript Objects. A property of an object can be explained as a variable that is attached to the object. Defines the characteristics of the object.
    Properties can be access with 2 simple ways : Dot ( . ) or [ ]
    myCar.Make=”BMW” / myCar [“make”] = “BMW”

  2. Which values do not have properties?
    null & undefined

  3. How can we access properties in a value (two ways)?
    Properties can be access with 2 simple ways : Dot ( . ) or [ ]
    myCar.Make=”BMW” / myCar [“make”] = “BMW”

  4. What are methods?
    Method are actions can be performed on object and stored as function definition.
    Example : .push //adds value to the end of an array.

  5. What are objects?
    Objects are values of arbitrary collection of properties.

  6. 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)?
    Because all of them only holds single value and they are immutable. Objects has the ability to equate 2 objects which is to equate their identity not simply the value. This ability to uniquely identify objects allows for the value to be mutable or changeable, as the information is referenced through the object itself not directly to the value.

  7. How do you define an object?
    Objects are groupings of data. They are defined within curly braces {} by sets of values given in the format of (name : “Ivan”, rating : 100,…). The language also has built-in functions for these objects. Object.keys(); for example, gives the property names that are associated with the object passed into it.

  8. What can you say about the mutability of Javascript objects?
    The mutability of Javascript Objects means that the value they contained can be changed. Unlike other data types such as string, Boolean, which will always keep the same value it was defined with. Allows much more flexibility in programming.
    jump to the sub-chapter called Strings and their properties.
    Think about the following questions:

  9. Why can’t you add new properties to a string variable?
    A string is not an object and they are immutable.

  10. What are rest parameters?
    Rest parameter is bound to an array containing all additional arguments given to a function.

  11. YAAA!

  12. 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 suitable when we want to do things like saving the data to a file or transferring it to another computer on a network.

  13. What is JSON?
    JavaScript Object Notation=> JSON
    Widely used as data storage and communication format on the web, even in language other than JS.

  14. What are the differences between JSON and the way programmers write objects in plain Javascript?
    Only simple expressions are allowed in JSON. There are no functions, bindings, comments, or computations.

:tada: :tada: :tada:
:tada: :tada:
:tada:


#127
  1. It introduces the problem of constructing data sets
  2. Array
  3. Almost all values have properties. They are attributes assigned to the value
  4. Null and undefined
  5. We can use: value.“property name” or value[“any binding that returns property name”]
  6. Properties that contains functions
  7. Objects are value types with an arbitrary collection of properties
  8. They allow to gather different value types in one object
  9. let “object” = {
    “property1”: ,
    “property2”: ,

    }
  10. It means that objects can change values as opposed to strings or booleans that are immutable
  11. Strings are not objects and are therefore immutable
  12. It’s a parameter pointing to an array with all the other arguments
  13. Serialization is needed to send data about objects that is stored in computers memory
  14. JavaScript Object Notation is a data storage and communication format
  15. In JSON notation all property names have to be in “”. No functions bindings and comments are allowed

#128

1.1. The first thing he needs is a data structure to store this information.

1.2. Array

1.3. Properties are expressions that access a property of almost all JavaScript value.

1.4. The exceptions are null and undefined.

1.5. Dot and a square bracket.

1.6. Properties that contain functions are generally called methods of the value they belong to

1.7. Values of the type object are arbitrary collections of properties

1.8. A object can hold different datatypes.

1.9. let object = {animal: squirrel, encounter: false};

1.10. he types of values discussed in earlier chapters, such as numbers, strings, and Booleans, are all immutable it is impossible to change values of those types. Objects work differently. You can change their properties, causing a single object value to have different content at different times.

2.1 Values of type string, number, and Boolean are not objects, and though the language doesn’t complain if you try to set new properties on them, it doesn’t actually store those properties.
Such values are immutable and cannot be changed.

2.2. A function to accept any number of arguments and put them in an array.

2.4. Conversion of saved data into a flat description.

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

2.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.
{
“squirrel”: false,
“events”: [“work”, “touched tree”, “pizza”, “running”]
}


#129

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 need to store different types of information together.

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?

built in functions which are able to retrieve some features of the argument values

4. Which values do not have properties?

the exceptions are ‘null’ and ‘undefined’

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

value.x and value[x]

  1. What are methods?

properties that hold function values, e.g. every string has a toUpperCase property: string.toUpperCase()

7. What are objects?

values of the type object are arbitrary collections of properties.

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

combine values of different data types, and multidimensional values

9. How do you define an object?

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

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

};

Inside the braces, there is a list of properties separated by commas. Each property has a name followed by a colon and a value.

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

This means that object values can be modified.

Strings:

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

Unlike objects, string is immutable

2. What are rest parameters?

It can be useful for a function to accept any number of arguments. For example, Math.max computes the maximum of all the arguments it is given.

To write such a function, you put three dots before the function’s last parameter, like this:

function max(…numbers) {

let result = -Infinity;

for (let number of numbers) {

if (number > result) result = number;

}

return result;

}

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

Ok

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

If you want to save data in a le for later or send it to another computer over the network, you have to somehow convert tangles of memory addresses to a description that can be stored or sent.

This is why we serialise the data. That means it is converted into a at description. A popular serialization format is called JSON (pronounced “Jason”), which stands for JavaScript Object Notation.

5. What is JSON?

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

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

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


#130

*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?
Ans: To keep daily log, only integers or strings are not enough. A proper data-structure is needed that can store collection of numbers, integers or arrays.

2. What variable type can be used in order to solve the problem of storing multiple values?
Ans: An Array can be used to store multiple values e.g.
let array1=[1,3,5,9,11];

3. What are properties in Javascript?
Ans: JavaScript is designed on a simple object-based paradigm. An object is a collection of properties, and a property is an association between a name (or key) and a value. A property’s value can be a function, in which case the property is known as a method. e.g. String has property called as length and can be invoked as below;
string.length

4. Which values do not have properties?*
Ans: null and undefined have no properties in JavaScript.

5. How can we access properties in a value (two ways)?
Ans: Properties can be accessed via “.” or via square bracket. e.g. string.length or string[“length”] can be used.

6. What are methods?
Ans: Properties that contain functions are generally called methods of the value
they belong to, as in toUpperCase is a method of a string.

7. What are objects?
Ans: Values of the type object are arbitrary collections of properties.

8. What problem do objects solve that cannot be solved with other value types we’ve learned so far (such as integer, string, array, boolean etc)?
Ans: Objects helps us combine values of varied properties. e.g. one part of object can be string, another party an array and still another one an integer. Below is example of object.
let person = {
name: “ali”;
age: 32;
profession: “civil engineer”;
hobbies: [“reading”, “programming”,“driving”]
};

9. How do you define an object?*
Ans: Object can be defined by enclosing key-pairs or data-sets within curly braces { and }.

10. What can you say about the mutability of Javascript objects?*
Ans: JavaScript objects are Mutable meaning their values can be changed.

11. Why can’t you add new properties to a string variable?*
Ans: Strings are immutable variables in JavaScript so nothing can be added or removed.

12. What are rest parameters?*
Ans: It can be used to make a function accept all the parameters given. e.g. below is one implementation of rest parameter (note the three dots … before start of function’s last argument).

function max(…numbers) {
let result = -Infinity;
for (let number of numbers) {
if (number > result) result = number;
}
return result;
}

13. What is serialisation and what is a use case of serialisation of data?*
Ans: Converting a data to flat-description is called “serialisation of data”. There are several ways of serialisation and nowadays most famous one is by using JSON.

14. What is JSON?*
Ans: JSON pronounced as Jason is “JavaScript Object Notation” and used as a form of serialisation to data to store and transmit data across web. It is also used on languages other than JavaScript.

15. What are the differences between JSON and the way programmers write objects in plain Javascript?*
Ans: In JSON all the variables and properties should be enclosed in double quotes. No function calls, bindings or any computation work is allowed. Comments are also not allowed in JSON. Below is one example of JSON notation.

{ 
  "first_name"  :  "Meesam", 
  "last_name"   :  "Ali", 
  "online"      :  true 
}

#131

in reading this chapter I am having trouble getting past the following Squirrel code:

function tableFor(event, journal) {
let table = [0, 0, 0, 0];
for (let i = 0; i < journal.length; i++) {
let entry = journal[i],
index = 0;
if (entry.events.includes(event)) index += 1;
if (entry.squirrel) index += 2;
table[index] += 1; }
return table;
}

What do the following lines accomplish and how do they work?

if (entry.events.includes(event)) index += 1;
if (entry.squirrel) index += 2;
table[index] += 1; }

not sure how to test my understanding of this code either… any help will be greatly appreciated.
thanks


#132

Part 1

  1. integers and strings only hold 1 value, some times you need to store more than that…
  2. data structures (arrays and objects) allow you to do this
  3. Almost all JavaScript values have properties. e.g. myString.length / Math.max These are expressions that access a property of some value.
  4. null and undefined
  5. 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.
  6. Properties that contain functions are generally called methods of the value
    they belong to, as in “toUpperCase is a method of a string”.
  7. objects are arbitrary collections of properties… you can store arrays and boolean together… These are created using braces to contain a list key/value pairs
  8. Object can store values of different types as integers, booleans, strings and arrays.
  9. var object = { day : “monday”, amount : 30}
  10. Unlike numbers, strings and Booleans, which are immutable values, objects can be moddified. Objects can have their properties changed

Part 2

  1. Values of type string, number, and Boolean are not objects, and though
    the language doesn’t complain if you try to set new properties on them, it
    doesn’t actually store those properties. As mentioned earlier, such values are
    immutable and cannot be changed.
  2. rest parameters allows a function to accept any number of arguments. To write such a function, you put three dots before the function’s last parameter. When such a function is called, the rest parameter is bound to an array containing all further arguments.
  3. Serialisation is converting data stored in memory into a flat description of what that data is. It is useful for when we want to do things like saving the data to a file or transferring it to another computer on a network.
  4. A popular serialization format is called JSON (pronounced “Jason”), which stands for JavaScript Object Notation.
  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.

#133

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 a data in a structure to keep all the information organized

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

What are properties in Javascript?
A value that can be pulled from a list or characteristics about the property. Suh as the length of an array or the index of a value.
Which values do not have properties?
Null and undefined
How can we access properties in a value (two ways)?
With a ("." ) and with square brackets
When using a dot, the word after the dot is the literal name of the property.
When using square brackets, the expression between the brackets is evaluated to
get the property name

7.What are methods?
methods are properties that hold fuction values.
ways to access or remove elements from the string. .push. pop() You can upper case or lowercase the string
8.What are objects?
The properties inside of the event you are designated, they are collections inside the property
let forsgate{
names: [ken’ jos’ lord]
events:[
What problem do objects solve that cannot be solved with other value types we’ve learned so far (such as integer, string, array, boolean etc)?
*They allow you you to access elements
9.How do you define an object?
It holds multiple values, keeps everything in a conformed shape within braces

What can you say about the mutability of JavaScript objects?
They are very mutable because if you change values. This is different from other datatypes such as strings, which always keep the same value it is defined with.
SECOND PART:

1.Why can’t you add new properties to a string variable?
because they are not objects and are immutable

2.What are rest parameters?

They denoted a functions last parameter with 3 dots before its name and are useful for functions that accept any type of argument. When the function is called the rest parameter i bound to an array containing all further arguments.

it can be useful to the function to accept a large number of arguments
when a function is called the rest paramater contains all further objects
(Feel free to skip the sub-chapter of Math object and Destructing)
3.What is serialization and what is a use case of serialization of data?
Its compressing all the data
4.What is JSON?
java script object notation
What are the differences between JSON and the way programmers write objects in plain Javascript?
All properties have to be surrounded with double quotes, and only simple data expressions are allowed comments are not allowed


#134

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 requirement to store large ammounts of varying data all in 1 place.

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

Objects and/or Arrays can fulfil this role. An array is actually just a special type of object.

3. What are properties in Javascript?

Properties are parts of an array. The are sometimes named by the developer to store data and some are built into javascript such as .length which returns the length of a variable.

4. Which values do not have properties?

Null and undefined do not have any properties.

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

Properties can be accessed by either: data.3 or data[5-2] The dot is used with the literal name and the square brackets can contain an expression

6. What are methods?

A method can be thought of as a property that has functional value. The method can return a value as well as alter the data structure to which it is attached.

7. What are objects?

Objects are a data structure than can contain many different types of data at the same time. An array is just one type of object where the object items are indexed. In a regular object items can be named, these are known as 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)?

As well as objects being able to store many different types of data that the same time. Objects make it easy for the developer to group this data as well as access and adjust it. Data in an object is mutable unlike a standard variable.

9. How do you define an object?

An object can be defined as follows:
let ourObject = {name: “Dave”, age: 34};

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

The mutability of objects and arrays means that values (or parts of) can be edited and adjusted. Primative elements are immutable meaning they can not be edited, however they can still be re-assigned.

SECOND PART:

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

You can not add new properties to a string value, a string value is a primitive element and is immutable, meaning once it is defined it can not be amended. Slice and other methods do still work however they only return a value without editing the original.

2. What are rest parameters?

A rest parameter is an argument for a function that references an array. For example:
myArray = [1,2,3];
function myFunction(0…myArray){
};

The above function would use 0, 1, 2 ,3 as arguments.

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

Java script can contain complex nested data structures, should this data need to be sent over a network it will need to be serialised. This simply means that the data structure is laid out in a flat string like sequence using a standard format. The serialised data can then be reassembled into the previous data structure by the recipient. Standard formats of serialsed data include JSON, XML & Yaml.

4. What is JSON?

JSON stands for Java Script Object Notation it is a commonly used format for serialised data, it is not restricted to use by JavaSript as other languages can use it.

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

Double quotes must always be used around property names. Also only data can be expressed no computational elements such as functions are allowed. Comments can not be included.


#135

Sorry guys, I’m writing this on my phone notes hence the UGLY format.

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?
How to compare different sets of information within lists is a new problem. The data sets values might have different data types, and number of entries.

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

An array can store multiple values.

3	What are properties in Javascript?

Properties are qualities associated with a value ie string length.

4	Which values do not have properties?

Null or Undefined

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

Using value.xyz or value[xyz]

6	What are methods?

A property that contains a function

7	What are objects?

objects are used to store arbitrary/multiple collections of properties

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

Objects can store different data types. See question 1.

9	How do you define an object?

Braces

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

Objects are mutable whereas numbers strings and Booleans are not.

SECOND PART:
1 Why can’t you add new properties to a string variable?
Because they are immutable

2	What are rest parameters?

Rest parameters allows us to represent any number of arguments as an array.

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

Nope!

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

Converts an objects data into a flat description or string

5	What is JSON?

JavaScript Object Notation - JSON, it’s a standard text format to present, transport and store data

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


#136
  1. A process through which a dataset is analyzed.
  2. An Array
  3. Properties are the details of objects, values, such as the .length property, and the math.max property.
  4. null and undefined
  5. with a dot and with square brackets.
  6. Properties that contain functions are generally called methods of the value they belong to, as in “toUpperCase is a method of a string”.
  7. Values of the type object are arbitrary collections of properties. One way to create an object is by using braces as an expression.
  8. objects can contain many other types of values, datatypes.
  9. with an = sign and held togather by braces.
  10. properties within objects can be added, removed, and reordered.

Part Two

  1. strings are primitives and are immutable which mean they cannot be changed.
  2. there are parameters which start with three dots (…) which allows for any number of elements to be passed in from an array.
  3. Data is converted into a flat description. It is widely used as a data storage and communication format on the Web, even in languages other than JavaScript.
  4. JavaScript Object Notation is a serialisation format widely used for data storage and communication.
  5. JSON has 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.

#137

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?
    Primitives such as strings and numbers cannot be organized in large but simple set. An array and object are better fit.

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

  3. What are properties in Javascript?
    An object is a collection of properties, and a property is asigned value.
    A propertys value can be a function, in which case the property is called a method.

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

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

  6. What are methods?
    A method is a function as a property of an object.

  7. What are objects?
    An object is a collection of properties.
    var anObject = {
    sum: function(a, b){
    return a + b;
    }
    };
    anObject.sum(2,5);
    //7

  8. What problem do objects solve that cannot be solved with other value types we have learned so far (such as integer, string, array, boolean etc)?
    All JavaScript values, except primitives, are objects. Object cam combine different primitives to solve designated task.
    Objects are mutable (customizable) and can fine tune, simpify, wanted solution, with less code.

  9. How do you define an object?
    An object is a type of function with variable for a particular task

  10. What can you say about the mutability of Javascript objects?
    A mutable object is an object whose state can be modified after it is created.

  11. Why cannot you add new properties to a string variable?
    Primitives types like strings or numbers are immutable and cannot have properties.
    var anObject = new Object;
    var a = “Hello!”;
    anObject.b = a;
    alert(anObject.a);//undifined (primitive - string)
    alert(anObject.b);// Hello! (non-primitive - object)

  12. What are rest parameters?
    Rest parameter allows us number of arguments as an array.
    Last parameter can be a “rest parameter” and is prefixed with … .

  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?
    Serialization is preparation of data in JSON string format.
    That JSON string can be easily called by function JSON.stringify()

  15. What is JSON?
    JavaScript Object Notation or JSON is an universal file format (like .XML) for storing and exchanging data.
    It is language independent.

  16. What are the differences between JSON and the way programmers write objects in plain Javascript?
    Java Script which is a browser environment language.
    JSON is minimalist look of complex javascript code and it is language-indepedent format. Easily readable and without comments.


#138

part one:

  1. variable types such strings and integers are only able to hold a single type of data with a chunk a of data, or a collection of numbers. The problem is having to extract the digits and convert them back to numbers to access them.
  2. Arrays can be used to list values
    3.expressions that access a property of some value.
    4.null and undefined
    5.A dot and square brackets.
    6.properties that contain functions are generally called methods of the value they belong to, as in “toUpperCase” is a method of a string".
    7.values of the type object are arbitrary collections of properties.
    8.objects help us to group a list of activities that would be very difficult to do with any other value type.
  3. You may think of objects as octopuses with any number of tentacles, each of which may have a name tattooed on it.
    10.The mutability of javascript objects means that the values they contain can be changed. This is different to other databases such as strings, which will always keep the same value it was defined with

second part:

  1. A string is not an object but a primitive type, so they are immutable.
  2. These are denoted by a function’s last parameter with 3 dots before its name and are useful for functions that accept any number of arguments. When the function is called, the rest parameter is bound to an array containing all further arguments.
  3. 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.
    5.JavaScript Object Notation is a serialization format widely used for data storage and communication.
  4. 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.

#139
  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 data sets, mutiple values that can be easily accessed.

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

  3. What are properties in Javascript?
    All Values bar null and undefined have properties in Javascript. Properties are the characteristics of the value. A single Value may have several properties assigned in JavaScript e.g. height, weight & age.

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

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

  6. What are methods?
    Properties that contain functions are generally called methods of the value they belong to.

  7. What are objects?
    Objects are values with 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)?
    Objects allow us to group several values into a single value

  9. How do you define an object?
    The object is defined by using braces as an expression and Inside the braces, there is a list of properties separated by commas.

  10. What can you say about the mutability of Javascript objects?
    Objects are mutable in JavaScript meaning they can have different values at different times unlike booleans, numbers and string.
    SECOND PART:

  11. Why can’t you add new properties to a string variable?
    A string is not an object so cannot store properties as with booleans and numbers. These values cannot be changed because they are immutable.

  12. What are rest parameters?
    Rest parameters allow us to represent any number of arguments as an array.

  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 to convert data into a flat description so it can be easily stored or sent to communicate with other computers over the Web.

  15. What is JSON?
    Stands for JavaScript Object Notation. It’s a data storage and communication format on the Web.

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


#140

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 such as strings and integers are only able to hold a single type of data. What our friend needs is a data structure that is capable of storing multiple values and datatypes in order to keep all of the information organised.

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

3. What are properties in Javascript?
Most Javascript values have properties. These define some characteristic about the values in a data structure, such as the length of an array or the index of a value.

4. Which values do not have properties?
Null and undefined are the exceptions that do not have properties.

5. How can we access properties in a value (two ways)?
Properties in a value can be accessed using a dot and the literal name of the property. e.g. array.length
Properties can also be accessed using square brackets, with the expression between the brackets being evaluated to get the property name. e.g. array[“length”]

6. What are methods?
Methods are properties that hold function values. These are special kinds of functions that only work on the value they belong to.

7. What are objects?
Objects are data structures that are capable of containing an arbitrary collection of properties. These are created using braces to contain a list key/value pairs separated by a comma.

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 special as they are able to hold as many different datatypes as we need.

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?
The mutability of Javascript objects means that the values they contained can be changed. This is different to other datatypes such as strings, which will always keep the same value it was defined with.

SECOND PART:

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?
These are denoted by a function’s last parameter with 3 dots before its name and are useful for functions that accept any number of arguments. When the function is called, the rest parameter is bound to an array containing all further arguments.

3. What is serialisation and what is a use case of serialisation of data?
Serialisation is converting data stored in memory into a flat description of what that data is. It is useful for when we want to do things like saving the data to a file or transferring it to another computer on a network.

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

5. What are the differences between JSON and the way programmers write objects in plain Javascript?
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.

4

Reply


#141
  1. The need to store sequences of values

  2. The array

  3. Properties are characteristics of variables and objects that we can access either with the dot notation or square brackets

  4. Null and undefined

  5. Using the dot notation or square brackets

  6. Properties that hold function values

  7. Arbitrary collections of properties

  8. Allows us to collect a series of properties in an organized fashion that has the characteristic of being mutable

  9. By using braces in which you have a list of properties separated by commas. The properties can be given values by placing a colon after their name

  10. It allows an object to have different values at different times

  11. It is not an object. It is immutable

  12. It is a parameter that is bound to an array of variable length that hold all subsequent arguments passed to it

  13. Converting data into a flattened form where there are no references to memory addresses, function calls , bindings or anything involving computations. A use case would be for preparing data for storage.

  14. JSON is a data storage and communication format often used on the internet

  15. In JSON properties must be surrounded in double quotes and only simple data expressions are allowed and no comments are permitted


#142
  1. Read the sub-chapter called The weresquirrel. What problems does this chapter introduce that cannot be solved with variable types such as strings or integers?
    The problem is that variable types such as strings and integers are only able to hold a single type of data. What we need is a data structure that can hold multiple values and datatypes.

  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 define characteristics of values, that can be accessed and processed independ from the value, e.g. length of a string and index of an array,

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

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

  6. What are methods?
    Methods are properties, that contain functions, e.g. push() and pop() are two methods to manipulate arrays

  7. What are objects?
    Objects are a collection of different 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 as many different datatypes as needed.

  9. How do you define an object?
    Braces are used to create objects. Properties inside the braces are separated by commas. Each property is named, follow by a colon and a value. (copied answer)

  10. What can you say about the mutability of Javascript objects?
    Objects are mutable. Their properties can be changed. Numbers, Strings, Boolean, … Are immutable. Their values can not be changed

SECOND PART:

  1. Why can’t you add new properties to a string variable?
    Because strings are immutable, and therefore values can not be changed

  2. What are rest parameters?
    Rest parameters allow any number of arguments to be accepted by a function. When such a function is called, the rest parameter is bound to an array containing all further arguments.

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

  4. Serialization is used to convert data in memory into a format, that can be used to store the data into a file or send it to over the network

  5. What is JSON?
    JSON is a common serialization format, that is widely used, in different languages, data storage and communication formats.

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