Data Structures (Arrays and Objects) - Reading Assignment

  1. Problems with need to work with a lot of different types, values, etc. of data.
  2. Arrays - Objects.
  3. Properties are the values associated with a JavaScript object.
  4. Null and undefined.
  5. e.g. objectName.propertyName and objectName [“propertyName”].
  6. Methods are functions stored in properties.
  7. Object is a collection of named values.
  8. Similar to answer No.1.
  9. The easiest way to create an object in JS is by object literal - defining and createing an object in one statement.
  10. Objects in JS are mutable.

SECOND PART:

  1. String variable is not an object ad is immutable.
  2. Rest parameters are bounded to an array, containing further arguments.
  3. Yeah, I saw this instruction too late, pfff:P:)
  4. Serializing data is converting it into a flat description for data storage and communication format.
  5. JSON is one of most popular serializing data converters, even used in some other programming languages as well.
  6. JSON has some restrictions, all property names have to be surrounded by double quotes, only simple expressions allowed, no computing (objects,…), etc.
  1. We will have to deal with quite lots of digital data out of which we have to extract, group, transform and use computations to rich conclusive result.

  2. Array

  3. The properties of the object defines it’s characteristics
    objectName.propertyName
    Property itself can be defined by assigning value to it.
    var newBike = new Object()
    newBike.color = ‘blue’;
    newBike.make = ‘BMW’;
    newBike.price = 35000;
    or newBike[‘color’] = blue;

  4. Almost all JS values have properties except ‘undefined’ and ‘null’.

  5. a, value.x - takes property of value x;
    b, value[x] - evaluates expresion x and uses result (string) as the name of the property

  6. Methods are actions, which can be executed on the objects. JS method is object’s property, containing function definition.

  7. Object is type of value, which contains properties. Almost all values in JavaScript are objects except primitive ones (without any properties or methods - can be number, string, Boolean, null or undefined). JS object is basicaly collection of named values, which are called properties.

  8. They can group together different types of values and methods as their properties.

  9. There are 3 ways to do it:

  • Using object literal - easiest way, single object is created and defined in one statement
    It is list of name:value pairs separeted by colons inside curly braces
  • Defining and creating single object with keyword new
  • By defining object constructor and then creating objects of the constructed type.
  1. JS objects are mutable, their properties can be changed, single value can have different content at different times. Bindings can be changeable or constant.
    JS variables and values like numbers, strings and Booleans are immutable.

SECOND PART:

  1. String variable is immutable and can’t be changed.

  2. The rest parameters make function to accept any number of arguments. The rest parameter is bond to the array with all further arguments. This way we can also spread array into another array. It is called by 3 dot notation.
    i. e. var numbers = [3, 7, 8, 11];
    console.log(1, 2, …numbers, 12);
    // [1, 2, 3, 7, 8, 11, 12]

  3. Serialisation is conversion of data into flat desctiption (JSON format). It is used for storage and transmition of data.

  4. JSON is serialisation format of data, it stands for JavaScript Object Notation. JavaScript can be converted to JSON with help of the function JSON.stringify

  5. JSON is similar to JS with few diffrences:

  • all the property names are surrounded by double quotes
  • only siple data expressions are allowed
  • function calls, bindings or anything involving computation is not allowed
  • comments are not allowed either

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, strings and integers, by themselves, are too limited to solve this problem. It requires more complicated types of data.

What variable type can be used in order to solve the problem of storing multiple values?
The Object variable, which can store complex data structures

What are properties in Javascript?
Properties are the values associated with a javascript object. They are usually changeable (mutable)

Which values do not have properties?
null and undefined

How can we access properties in a value (two ways)?
A dot followed by property name such as .length
For an array, square brackets and index number such as [5]

What are methods?
Methods are functions that extract object properties using the syntax objectName.methodName() and an example being stringName.toUpperCase()

What are objects?
‘JavaScript objects are containers for named values, called properties and methods’ (quoted from W3Schools.com)

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 contain multiple data types (as well as their methods)

How do you define an object?
the simplest way is as an object literal such as:
var person = {firstName:”Mary”, lastName:”Riley”, age:”35”, height:”170cm”, sex:”female”}

What can you say about the mutability of Javascript objects?
The values held within javascript objects can be changed ie the value attribute can be changed (assuming it is writable)

SECOND PART:
Why can’t you add new properties to a string variable?
A string variable is not an object. It is immutable.

What are rest parameters?
These allow an unspecified number of arguments (as an array)

What is serialisation and what is a use case of serialisation of data?
It is the process of converting the name:value pairs of an object to a string by using methods such as JSON.stringify() and JSON.parse()
This process converts data into a form that can be more easily transferred over a network, or stored in an array or some sort of file (such as .csv)

What is JSON?
JavaScript Object Notation, commonly used for transferring data over the Web. It is replacing XML in this respect.

What are the differences between JSON and the way programmers write objects in plain Javascript?
Property names are surrounded by double quotes. Only simple data expressions are allowed, and comments are not allowed.

First part:

  1. The problem is to store multiple values in a data structure.
  2. Array.
  3. Characteristics of a value.
  4. Nulls, undefined.
  5. Via value.x and value [x].
  6. Methods are properties that contain functions.
  7. Values of type object are arbitrary collections of properties.
  8. Objects can hold values of different datatypes.
  9. An object is defined by putting square brackets around the variables.
  10. Mutability of objects means that the variables within are dynamic and can be modified by the program.
    Second part:
  11. Because a string variable is not an object that can be given properties. Strings have a set of their own built in properties though.
  12. Rest parameters allow us to represent an indefinite number of arguments as an array.
  13. Serialisation is the conversion of data stored in memory into a simple string-like description of what this data is.
  14. Is a popular serialization format and is widely used as a data storage and communication format on the Web.
  15. In JSON, all property names must be surrounded by double quotes and only simple expressions are allowed.
  1. Read the sub-chapter called The weresquirrel. What problems does this chapter introduce that cannot be solved with variable types such as strings or integers?
    Here we are introduced to problems such as having to store different types of values, something that’s not possible with a simple Array.

  2. What variable type can be used in order to solve the problem of storing multiple values?
    If the values are all of the same type, we could use an Array.

  3. What are properties in Javascript?
    Properties are the characteristics or dimensions of a value.

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

  5. How can we access properties in a value (two ways)?
    As an example, we can use value.property or value[“property”]

  6. What are methods?
    Methods are properties in the form of functions, or in other words, functions stored in properties.

  7. What are objects?
    Objects are arbitrary collections of properties, which can hold different types of values. While in an Array we can only have one type of values, in Objects we can store every kind of values.

  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 allow to hold and reference different types of values.

  9. How do you define an object?
    We can create a binding, and the use curly braces to hold the properties of the object:
    let myCar = {wheels: 4, sound:“vroom”}

  10. What can you say about the mutability of Javascript objects?
    Objects in JavaScript are mutable, as we can change their properties values.

Second Part

Why can’t you add new properties to a string variable?
String variables, just like Booleans and numbers, are immutable, hence we cannot add new properties to them, although they already come with built-in properties (e.g., slice, length…)

What are rest parameters?
Rest parameters consist of an array of an undetermined number pf elements. They allow a function to have as parameters an initially unknown number of parameters.

What is serialisation and what is a use case of serialisation of data?
Serialisation is the conversion of tangles of memory addresses into a description that can be stored or sent. This will allow to send data from one computer to another through the network, without having to send the whole computer memory.

What is JSON?
JSON stands for JavaScript Object Notation, and it’s used as a data storage and communication format on the Web.

What are the differences between JSON and the way programmers write objects in plain Javascript?
In JSON, the property names also go between double quotes, and only simple data expressions are allowed—no function calls, bindings or comments.

  1. The weresquirrel. What problems does this chapter introduce that cannot be solved with variable types such as strings or integers?
    working with large chunks of data. An array systems is then presented to act as a store of value for the different recorded strings in the array.
    for instance. let listOfNumbers = [2, 3, 5, 7, 11]
    console.log(ListOfNumbers[2])
    // 5

  2. Arrays are a variable that can be used to store multiple data types.
    eg. let monthOne = [ “Janvier” ];
    console.log(monthOne)

  3. Properties. These are like identifiers within an object that can be invoked, in order to harness their characteristics. E.g. console.log(Math.max [2.3,-4,5,7]

  4. In javascript there are two exceptions that do not have properties. “Null” and “Undefined”

  5. Properties can be accessed in two ways: With "a dot’ and with ‘square brackets’
    i.e. value.x or value[x]

  6. Methods are a way to affect or change the parameters described in an array.
    e.g. let doh = “laugh”
    console.log(doh.toUpperCase());
    // – LAUGH
    OR
    Let sequence = [1,2,3]
    sequence.push(4);
    sequence.push(5);
    console.log(sequence);
    // – [1,2,3,4,5]
    console.log(sequence.pop());
    // – 5
    console.log(sequence);
    // – [1,2,3,4]

  7. objects: In JavaScript, objects are king. If you understand objects, you understand JavaScript.
    In JavaScript, almost “everything” is an object.

  • List item

  • Booleans can be objects (if defined with the new keyword)

  • Numbers can be objects (if defined with the new keyword)

  • Strings can be objects (if defined with the new keyword)

  • Dates are always objects

  • Maths are always objects

  • Regular expressions are always objects

  • Arrays are always objects

  • Functions are always objects

  • Objects are always objects
    All JavaScript values, except primitives, are objects.

  • In JavaScript there are 5 primitive types: undefined , null , boolean , string and number . Everything else is an object.

creating an object;
let day1 = {
squirrel: false,
events: [“work”, “touched tree”, “pizza”, “running”]
};
console.log(day1.squirrel);
// – false
console.log(day1.wolf);
// – undefined
day1.wolf = false;
console.log(day1.wolf);
// – false

  1. Objects tie different properties together to express a single condition. This allows programmers to better represent how a system should behave.
  2. an object can be defined as variables that can contain many other values/properties.

<html…>
<body…>

<script…>
var person = {

firstName : "John",
lastName  : "Doe",
age       : 50,
eyeColor  : "blue"

};

document.getElementById(“demo”).innerHTML =
person.firstName + " " + person.lastName;
</script…>

//-- John Doe

// don’t include the 2 dots in the tags.

  1. Mutable is a type of variable that can be changed.

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. 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.
e.g.

let words = [“never”, “fully”];
console.log([“will”, …words, “understand”]);
// → [“will”, “never”, “fully”, “understand”]

  1. serialisation: Serializing Objects. Object serialization is the process of converting an object’s state to a string from which it can later be restored.

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

  3. Serializing Objects. Object serialization is the process of converting an object’s state to a string from which it can later be restored. ECMAScript 5 provides native functions JSON.stringify() and JSON.parse() to serialize and restore JavaScript objects. These functions use the JSON data interchange format.

  1. The problem is in storing strings and numbers in one array without any complicated parsing.

  2. Objects can store multiple different variables and that solves the problem

  3. We use property to bind a value to an object. Object can have multiple properties.

  4. Null and undefined are defined as values with no properties

  5. We can access values using build in methods - . (dot) or []

  6. Methods are properties that hold function values. We call them with .(dot) or [] over an object.

  7. Objects are a collection of properties. (values and functions).

  8. Objects can contain any number of different types of variables.

  9. We define objects with {}, its properties (any type) listed separated by coma within the brackets.

  10. Objects are mutable, values can be changed. We can’t do that in primitive type variables (string, int, boolean)

  11. String is a primitive type and is immutable, can’t be changed.

  12. Rest parameter enables a function to accept any number of parameters. It is defined with … (three dots) and it is bound to an array containing all arguments.

  13. Objects store only addresses of it’s properties, not the actual data. In order to get the actual data we have to load all the data and somehow save it as a standardized format data. The process of getting the data and converting it to a standardized format is called serialization. Best known use case is sending the data over the internet.

  14. JSON is a standardized data format, used for sending serialized data over the internet.

  15. Differences between JSON and plain js code:

    • property names must be in double quotes
    • only simple data is allowed (no function calls, no variables,…)
    • no comments
  1. It introduces to store multiple values which strings and integers can’t do.

  2. Arrays

  3. Properties is something that is attached to a binding or Object. For an example when you want the max number you type “Math.max” which is the Math-Object with the “max”-property. An other example is when you have bound a String and use the length property:
    let aString = “Hello world”;
    console.log(aString.length);
    -> 11

  4. “null” and “undefined” does not have properties

  5. The first way (most used I believe) is with a dot between: Array.length
    The second way is with square brackets: Array[“length”]

  6. Methods is the same as properties except they are based on function values. They only work with the value they belong to.

  7. An object is a collection of properties. One way to create objects is by using braces.

  8. Objects can have all types of values in it.
    Example:
    let anObject = {
    color: “red”,
    width: 100,
    height: 43,
    weight: 98
    }

    // You can get the width from this object by typing:
    console.log(anObject.width);

  9. You define it as a normal binding.

  10. Objects in Javascript have properties that you can change and modify. Strings, booleans and integers values can’t be changed (aka immutable).

Second part:

  1. Because Javascript and other languages have made pre-written properties for a string which is not an Object.

  2. It is used for functions to accept any types of arguments. You put three dots before the parameter that is an array. Then it uses the array’s values as arguments.

  3. It is a conversion from an object to a string (from data-stored memory to a flat description). You can save this into a file or transfer it over to another computer.

  4. It is a syntax used for storing and exchanging data.

  5. Objects:
    let football = {
    size: 5,
    color: “red/black”,
    brand: “Nike”
    }

    JSON (properties with double quotes):
    let football = {
    “size”: 5,
    “color”: “red/black”,
    “brand”: “Nike”
    }

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? booleans, strings and integers are too simple and in order to build more complex structures we need more complex tools
What variable type can be used in order to solve the problem of storing multiple values? arrays
What are properties in Javascript? properties are the values assosciated with a js objects
Which values do not have properties? null, undefined

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

What are methods? properties that contain functions

What are objects?
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)?
How do you define an object?arbitrary collections of properties

What can you say about the mutability of Javascript objects?
numbers, strings and booleans are immutable, objects are mutable
SECOND PART:

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

What are rest parameters? is bound to an array that contain all further arguments
(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? converting into a flat description; it is widely used as a communication format on the Web
What is JSON? javascript object notation - a popular serialisation format
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, only simple data expressions are allowed, no function calls, bindings,nothing that involves computations, comments are not allowed in json

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 set with more than one data
    What variable type can be used in order to solve the problem of storing multiple values?
  • array
    What are properties in Javascript?
  • gaining information of the specific variable
    Which values do not have properties?
  • null and undefined
    How can we access properties in a value (two ways)?
  • . method and [] method
    What are methods?
  • properties that hold function value
    What are objects?
  • an array of log entities hold different variables
    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)?
  • store diff variables together
    How do you define an object?
  • var list = {name:", value=}
    What can you say about the mutability of Javascript objects?
    object can change value/ boolean string number cannot

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

  • string is immutable
    What are rest parameters?
  • for considering parameters in the format of array having any number of terms
    (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?
    What is JSON?
  • a standard data set format
    What are the differences between JSON and the way programmers write objects in plain Javascript?
  • JSON : all property names have to be surrounded by “”, ad only simple data expression allowed
  1. What problems does this chapter introduce that cannot be solved with variable types such as strings or integers?
    storing different types of data and multiple values.

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

Arrays are used to store multiple values in a single variable.

3.What are properties in Javascript?
properties are characteristic describing the values in a data structure {named values, in JavaScript objects, are called properties}

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

5.How can we access properties in a value (two ways)?
Either with a dot (value.x) or with a square brackets (value[x]).

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

7.What are objects?
objects are 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)?
grouping information together.

9.How do you define an object?
define and create an object,inside curly braces {} list of name:value pairs

var carObject = { manufacturer: ‘toyota’, year: 2015, mileage: 50000};

  1. What can you say about the mutability of Javascript objects?
    javascript objects values can be modified unlike numbers,srting and boolean which are immutable.

SECOND PART:

1.Why can’t you add new properties to a string variable?
value of strings are immutable and cannot be changed unlike objects which can be changed.

2.What are rest parameters?
rest parameters are denoted by three dots before the function’s last parameter. Useful for a function to accept any number of arguments.

  1. 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
enable modern browser to make additional HTTP request from browser to server without having to reload the whole page.

  1. 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. So no function calls, bindings, or anything that involves actual computation. Also, comments are not allowed in JSON.
  • 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 are awkward ways to introduce a log format where events that are to output a boolean value change by entry.

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

  • What are properties in Javascript?
    properties are certain operability factors that are generally available in values, such as math.max = the highest number in arguments, value.length = length x within a value, etc.

  • Which values do not have properties?
    NULL and UNDEFINED

  • How can we access properties in a value (two ways)?
    it can be used by adding a period to call the property or done with square brackets “[]”.

  • What are methods?
    properties that contain functions

  • What are objects?
    Objects are variables that contain methods and 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)?
    Objects allow more complex systems that can be used with boolean, arrays and strings.

  • How do you define an object?
    a variable with assignable properties

  • What can you say about the mutability of Javascript objects?
    I suppose it creates a certain factor of reality where something can change over time according to the environment or how it is called. I can see this allowing complexity and more wholesome functionalities.

SECOND PART

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

What are rest parameters?
Rest parameters allow an indefinite number of arguments as arrays.

(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?
serialisation is compiling all storage addresses to certain information and compiling to one description.

What is JSON?
JSON helps to switch from javascript to another format that can be used for serialisation of data.

What are the differences between JSON and the way programmers write objects in plain Javascript?
JSON is used solely to switch data from one format to another and does not contain the flexibility of Javascript.

What problems does this chapter introduce that cannot be solved with variable types such as strings or integers?
  • string and intergers cannot contain multiple values.
    What variable type can be used in order to solve the problem of storing multiple values?
  • arrays.
    What are properties in Javascript?
  • properties are information (or possibly a function) about a variable.
    Which values do not have properties?
  • null and undefined values do not have properies.
    How can we access properties in a value (two ways)?
  • value.property or value[property]
    What are methods?
  • methods are properties that are functions. they perform a function on the variable in question.
    What are objects?
  • objects are key/value pairs that can hold multiple values of differing types, and can be nested to provide even more flexibility in the data stored within.
    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 multiple values of differing types. Other variables hold only one type.
    How do you define an object?
    using {}, and the key: value statement. eg:
    let x = {
    shape: square
    colour: blue
    }
    What can you say about the mutability of Javascript objects?
  • object variables are mutable unlike other variable types.

SECOND PART:

Why can’t you add new properties to a string variable?
  • they are immutable unlike objects.

    What are rest parameters?

  • Rest Parameters allow for an undefined number of additional parameters to be sent as arguments to a function.

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

  • serialisation is the sending of the actual values of a variable outside of the program - ie saving info to a file, or over the network to another computer. Ordinarily a variable only stores the memory location of a value, so sending a variable out of the program wil send a memory address, which would be meaning less to the remote party. Therefore, serialisation ‘opens up’ the actual contents and formats them for sending out.

    What is JSON?

  • JSON stands for JavaScript Object Notation, and is a standardised way of serialising data.

    What are the differences between JSON and the way programmers write objects in plain Javascript?
    key values must be wrapped in quotes (""), function calls, bindings and comments are not allowed.

  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?

This chapter introduces problems that cannot be readily solved using simple data types such as numbers, strings and Booleans. Instead, the problems in this chapter are most efficiently addressed by means of more complex data structures.

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

An array

  1. What are properties in Javascript?

Properties are values associated with a JavaScript data type or object.

  1. Which values do not have properties?

Null and undefined

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

Two ways to access properties are with a dot (e.g. value.length) or with square brackets (e.g. value[x]

  1. What are methods?

Methods are properties that contain functions. For example .max is a method of a number.

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

Problems requiring data structures comprised of arbitrary collections of properties (as with the weresquirrel example). Moreover, we need to use objects whenever we have problems that require us to be able to change properties. Objects are mutable so we can change their properties but the other value types we’ve learned so far are immutable; we cannot change the content of the value of those types.

  1. How do you define an object?

Place a list of properties separated by commas inside curly braces. Each property has a name followed by a colon and a value. Properties whose names aren’t valid binding names or valid numbers have to be quoted.

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

Javascript objects are mutable. That means you can change their properties, causing a single object value to have different content at different times. That means we have to distinguish between two references to the same object and 2 objects that happen to contain the same properties. In the former case if both objects are grasping the same object then if we change the value of one of the objects we also will change the value of the other object. However, when 2 objects happen to contain the same properties then changing the value of one object does not affect the value of the 2nd object. Also, when we compare objects with JavaScript’s == operator, it compares by identity: it will produce true only if both objects are precisely the same value. Comparing different objects will return false, even if they have identical properties.

Sub-chapter: Strings and their Properties

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

The type string is not an object and if you try to set new properties for a string Javascript doesn’t actually store those properties. So even if you define and assign a value to a new property for a string variable, the new property will not be incorporated into the string variable.

  1. What are rest parameters?

Rest parameters allow a function to accept any number of arguments. When the function is called the rest parameter is bound to an array that will hold all further arguments.
Rest parameters can also be used to call a function with an array of arguments. This “spreads” out the array into the function call, passing its elements as separate 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?

  3. What is JSON?

JSON is a serialization format used to save data in a file for later or to send it to another computer over the network

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

When programmers write objects and arrays in plain Javascript the objects and arrays are stored in the computer’s memory as sequences of bits holding the addresses of their contents. JSON converts the stored address pointers and content at those addresses into flat descriptions of the objects and arrays enabling them to be stored in files and transferred over the network. (This is significantly preferable to transmitting a copy of your computer’s memory and pointers to addresses in the memory over the network).

  1. It would be convenient to store more values in only one value, and to access them all with one command

  2. Arrays and objects

  3. They are characteristics of a specific element - string, array or object

  4. Only null and undefined values

  5. Either with a dot operator, or with a square brackets - the second one is used when the name of the property isn’t valid variable name, and the property is found out after evaluating the expression in brackets

  6. Methods are pieces of code or functions, that can be executed on some element (strings, arrays, objects)

  7. These are elements that can have multiple properties, and we can assign them arbitrary amount of properties

  8. The properties of an object can be changed, compared to other elements - and also they are very flexible in their properties

  9. As a set of properties given a specific name

  10. They are mutable, can be changed after being created

  11. Because it is limited, and adding new properties is possible only with objects

  12. They are represented by three dots, and they allow the function to be fed by any amount of parameters

  13. I didn’t skip ip, because I like Math :slight_smile:

  14. Creating a common data structure for sending variables and other data content over the internet

  15. JavaScript Object Notation, the way of formatting data to transmit them over the network, so that they could be easily readable

  16. In JSON, there is a need to surround all property names in double quotes

Data Structures

I found this chapter very confusing. Some of the explanations don’t actually work. Not enough examples of the complex stuff but lots of examples of easy stuff.

Part 1
2. That variable types Arrays and Objects can be used to store multiple values.
3 The book is confusing as hell on this and doesn’t make sense and also doesn’t work. However from looking at other sources like “https://www.tutorialspoint.com/javascript/javascript_arrays_object.htm”. properties contain information about a variable.
4. null and undefined do not have properties.
5 They can be accessed - variable.property name eg Math.PI -returns pi, a.length; returns the length of array a. [value] allows access the variable content. eg a = [1,2,3,4,5]; a[2]; returns the value 3.
6. Methods are function properties. eg a.toLowerCase(); returns everything in lowercase in string a.
7. An object is a collection of related data,properties and methods.
8. objects can store collections variables, have functions that can do operations on those variables and can contain other objects.
9. Objectname = {
variable : value,
variable2 : value,
variable3 : value,
etc…
};
10. Objects in javascript are mutable in that you can change their properties.
Part 2.

  1. You cannot add new properties to string because strings are immutable.
  2. rest parameters are functions that can take anynumber of arguments. syntax is functionname(…variable){}

4.Serialisation is the process in which you convert stored data in memory to a flat format that can be sent to another machine or stored on a file.
5 JSON or JavaScript Object Notation is a popular serialization format used by many web sites
6 Property names have to have double quotes and no function calls or anything that requires computation.

Part One

  1. Problems that require values of different types to be grouped together with some sort of logical relation.

  2. If the multiple values to be stored are of the same type then an Array is the answer, however if what is needed is to make a collection of different types of values an Object is the tool you need.

  3. Properties are additional bindings that are associated with a value that hold other values that describe or operate on their parent value.

  4. The null and undefined types have no properties.

  5. Through either dot notation that names a property directly
    "Some string".length; or by square bracket notation that evaluates an expression to look for a property "Some other string"["length"];

  6. A method is a property that holds a function as its value.

  7. An object is a collection of any number of properties.

  8. Objects can store any number of logically related properties with any value, including functions. This makes for a powerful capacity to build abstractions which model the way we think about and approach solving problems as humans.

  9. An object definition in JavaScript is a code block enclosed in curly braces which lists the parameters separated from their values by a colon and from one another by commas:

let someObject = {
    prop1 : "A value!",
    prop2 : 2,
    prop3: false
}
  1. Unless declared as a const Object properties are completely mutable, meaning that they can be added to or deleted from the object at any time. The values contained by their properties are always mutable though, even when const.

Part 2

  1. Because strings and other standard types are immutable and cannot have their properties changed.

  2. Rest parameters take any number of arguments and combine them into an array to be used within the function.

  3. Serialization is a flat value representation of can be used to transfer or store data without communicating its in memory structure.

  4. JSON is a short for JavaScript Object Notation and is a method of serializing objects as string values.

  5. In JSON all property names are surrounded by double quotes and object properties can only contain simple values, no bindings or functions calls.

  1. the need to store information that requires a new combination of data into more “objects” that are real world based.also the need to store multiple /repeating types.
    2, an array
  2. an expression that refers to a property of something
  3. null and undefined
  4. a dot or square brackets
    6.functions on an object
    7.an object is an entity that stores multiple properties and methods
  5. storing multiple values
  6. via {} brackets
  7. this feature allows you to change underlying properties and values.

Part Two.

  1. because a string is not an object as such.
  2. a rest parameter is a parameter that holds a variable number of passed arguments using the … notation.
  3. thanks
  4. serialisation means taking data in a certain format and flattening it typically in a need to transfer data from one system to another.
  5. it is an object notation whereby data is represented by the data object name and its contents in a pairing format.
  6. double quotes required plus not possible to embed other bindings.

Part One

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?
Logging of data

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

What are properties in Javascript?
Expressions that access a property of some value

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

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

What are methods?
Properties that contain functions

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)?
Values of the type object are arbitrary collections of properties.

How do you define an object?
You can see them as long, flat octopuses with all their tentacles in a neat row, labeled with numbers.

What can you say about the mutability of Javascript objects?
You can change their properties, causing a single object value to have different content at different times.

Part Two

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

What are rest parameters?
A parameter that can hold any number of arguments

What is serialisation and what is a use case of serialisation of data?
Serialisation: Data is converted into a flat description.
Use case: If you want to save data in a file for later or send it to another computer over the network

What is JSON?
A popular serialization format

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.