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?
Finding relations between values.

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

3. What are properties in Javascript?
properties of values, e.g. size or color of a jacket

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

5. How can we access properties in a value (two ways)?
value.x
value[x]
where x is the property of the value

6. What are methods?
properties that contain functions.

7. What are objects?
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)?
to hold arbitrary collections of properties

9. How do you define an object?
var object = {
property1: value,
property2: value
};

10. What can you say about the mutability of Javascript objects?
contrary to strings, numbers and boolean values, object values CAN be changed and are therefore mutable.

SECOND PART:

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

2. What are rest parameters?
parameters in an array that are passed individually into a function

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

4. What is serialisation and what is a use case of serialisation of data?
converting tangles of memory addressess into a flat description that cab saved and sent over the network.

5. What is JSON?
JavaScript Object Notation - a popular serialization format for data storage and communication on the Internet.

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

1 Like

FIRST PART.

  1. The problem is to determine how the transformation into squirrel-shape is causally linked to certain events or activities in the life of an occasionally squirrelizing protagonist. To solve this problem it is convenient to introduce an object data type that records not only a day’s events (or activities) but also the occurrence or non-occurrence of a late-day squirrelization.
  2. The overall type is an array (journal[days]) in which each element (i.e., each day) is an object of the form { event: [list of events/activites,…] (this is another array), squirrel: boolean value (true or false)}
  3. The properties of a value of type object are the named categories that the object comprises: {property_1: [list of values of property_1], … ,property_n: [list of values of property_n]}. More generally, though, properties in Javascript are simply properties of values of just about any conceivable type.
  4. ‘null’ and ‘undefined’.
  5. By using the format ‘value.x’ or ‘value[ x]’.
  6. Methods are properties that contain functions.: value.property(…) signifies the use of a method whereas value.property signifies the determination of a property. (Is this really a meaningful distinction?)
  7. Objects essentially are lists of properties (enclosed by braces) with corresponding lists of property values: {property_1: [list of values of property_1], … ,property_n: [list of values of property_n]}.
  8. By means of objects we can solve the problem of describing entities that are naturally characterized by multiple variables of multiple types.
  9. By using the syntax {property_1: [list of values of property_1], … ,property_n: [list of values of property_n]}.
  10. objects are mutable insofar as properties can be added to or subtracted from them and insofar as property values can be added or subtracted as well. Moreover, apart from the issue of mutability, there also is the related issue of identity: if x and y are variables and x=1 and y=1, then x==y is true, but not so for objects. For if x and y are independently defined objects with identical properties and identical property-value sets, then x==y is false because x and y are pointing to different blocks of memory. So the only way for x==y to be true in this latter case is for y to be defined by the equation y=x. (My question here is whether variables with different names are not also associated with different memory regions and whether they should therefore be subject to the same identity rules as objects.)

SECOND PART:

  1. Because unlike objects, strings are not collections of independent properties but simply are strings. A string may have certain properties by virtue of being a string, but it cannot be given a new property that is unrelated to its ‘stringness’.
  2. The rest parameter syntax ‘function functionName( …parameters)’ allows us to define a function in dependence on an unspecified number of parameters.
  3. As a math guy, I do feel free to skip this one.
  4. Serialization, by definition, is the process of converting data into a format that is suitable for storage and/or external transmission.
  5. JSON is an acronym for ‘JavaScript Object Notation’ and is descriptive of a set of notational conventions that are used for object data storage and external transmission.
  6. In JSON, all property names are converted into strings, using quotation marks, computations involving functions and/or variables are not permitted, and comments are also not allowed.
1 Like
  1. Arrays provide a data type specifically for storing and retrieving sequences of values.
  2. Arrays
  3. Almost all JS values have properties. myString.length for example is an expression that accesses the property of a particular value.
  4. Null
  5. Using a . and also 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 can contain many values and datatypes.
  9. Objects are defined within braces. Properties separated by commas where each is named and assigned a value.
  10. You can change the objects’ properties, causing a single
    object value to have different content at different times.

Second Part:

  1. String variables are immutable and cannot be changed, their value will always remain the same.
  2. Rest parameters are useful for a function to accept any number of arguments. It is bound to an array containing all further arguments but not the parameters that come before it. It is represented by … followed by the parameter.
  3. Serialisation refers to data being converted into a flat description.
  4. Javascript Object Notation (JSON) is a serialisation format used for data storage and communication on the web.
  5. JSON looks similar to JavaScript’s way of writing arrays and objects, with a
    few restrictions. All property names have to be surrounded by double quotes,
    and only simple data expressions are allowed—no function calls, bindings, or
    anything that involves actual computation. Comments are not allowed in
    JSON.
1 Like
  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 the problem of a set of data (values) for each day (variable). Strings and integers do not solve the issue of multiple vales for one variable

  2. What variable type can be used in order to solve the problem of storing multiple values?
    In order to store multiple values for one variable, we use an array. To assign an array of values to a variable, we define a name and then use the square brackets to input the array values, separated by a comma.

  3. What are properties in Javascript?
    Properties are values associated with an object. For example the length property of a string is equal to the number of characters the string has, whereas the length property of an array is equal to how many values are stored in the array.

  4. Which values do not have properties?
    Null and undefined, by definition, have no properties.

  5. How can we access properties in a value (two ways)?
    We can access values by using the objectName.property method to fetch that particular property (only works if you know the property name) or by using the objectName[property] method which extracts a property based on the expression in the square brackets (for example to use the third value in an array).

  6. What are methods?
    Methods are actions that can be performed on objects.

  7. What are objects?
    Almost anything in JavaScript is an object, except for JavaScript Primitives. Primitive values have no properties or methods - strings, numbers, booleans, null and undefined values are all primitive data sets. Objects are containers for a collection of named values, properties and methods.

  8. What problem do objects solve that cannot be solved with other value types we’ve learned so far (such as integer, string, array, boolean etc)?
    Objects solve the problem of mutability as well as flexibility. Mutability will be addressed in question 10, flexibility is solved as objects allow you to store different data types as values, including functions. This makes them a very powerful tool to be able to call on throughout a program.

  9. How do you define an object?
    The easiest method (in terms of simplicity and readability) to define an object is the object literal method, whereby you define and create the object in a single statement. To do this you use name and value pairs separated by a colon, inside of a set of curly brackets.
    For example:
    var shoppingList = { bananas: 4, biscuits : 2, eggs : 6}
    Another method for creating an object is by using the Keyword new.
    For example:
    var shoppingList = new Object (){
    shoppingList.bananas = 4;
    shoppingList.biscuits = 2;
    shoppingList.eggs = 6;
    }

  10. What can you say about the mutability of Javascript objects?
    Strings and numbers are values, which are immutable, the values themselves cannot be changed, the value stored by the variable name can be changed but not the value itself. Objects, and the properties and methods they contain, are mutable. They are addressed by reference, not by value and therefore the properties of an object can be changed.

SECOND PART:

  1. Why can’t you add new properties to a string variable?
    Unless you define the variable as an object, adding new properties to the variable won’t be stored in the memory. The program will allow you to add them, as the language doesn’t care, but the properties you add won’t be stored, only the immutable value that is defined. You can change the binding that refers to that value and point it to a new value that has different properties, but you can not alter the properties of the original string variable.

  2. What are rest parameters?
    Rest parameters allow us to create a function with an undefined set of parameters. The rest parameter syntax (…), which must be used for the last argument when you define the parameters of the function, allows us to represent an undefined number of arguments as an array. These arguments can be defined later and be passed through the function as an array.

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

  4. What is serialisation and what is a use case of serialisation of data?
    Serialisation is a way of storing or transferring data. It is a way of formatting the data with a flat description (no function calls or computation) that can be easily read and conveyed, even between languages other than JavaScript.

  5. What is JSON?
    JSON stands for JavaScript Object Notation and is one of the more widely used serialisation formats.

  6. What are the differences between JSON and the way programmers write objects in plain Javascript?
    The diffierences in JavaScript Object Notation and the standard way of writing objects into a plain JavaScript program is that all property names must be encapsulated in double quotations marks and only simple data expressions are allowed (no function calls, no bindings and nothing that involves actual computation).

1 Like
  1. Problems that involve storing and using several data points that can fluctuate in number of needed data points.
  2. arrays and objects
  3. Properties access a property of your variable. Ex: array.length gives length of array.
  4. null and undefined
  5. with dot, ex string.length and with brackets, ex value[x]
  6. methods manipulate the input. yourtext.toUpperCase returns your string all in uppercase letters. push and pop add and remove values from an array.
  7. Objects can include several different data structures, integers, strings, arrays and so on.
    8.Keeping track of complex datastructures, for instance user data (which can have several different types of values)
  8. by curly braces, object = { a = 69, string : " donkey kong", bananas : [“green”, “yellow”, “brown”]};
  9. Javascript objects are mutable, you can change their properties.

Part II

  1. Because strings are immutable
    2.Rest parameters let you pass a function basically infinite number of parameters, ex. max(…numbers)
  2. :slight_smile:
    4.Serialisation is organizing data in a straight forward series used when transferring data to a file or anohter computer so they dont have to have a whole copy of your computers memory and adresses to the data that is needed.
  3. JSON is JavaScript Object Notation and is a serialisation format.
  4. JSON has restrictions, it cannot contain function calls, bindings or anything that involves actual computation.
1 Like

Hi @ArvidK,

Your answers are mainly OK :ok_hand:

Here are some additional comments and clarifications:

That’s correct… and we can also write our own methods for objects that we create. A method is basically a property whose value is a function.

Sort of… but it’s more than that…
Objects allow related data of different value types (including further sub-sets of data within nested objects or arrays) to be grouped and stored together under one roof in a single value. Unlike arrays, objects do not order their properties’ values in any particular sequence, and their property names can be any string. Arrays are indexed sequences of values (usually of the same type).

… I think we need to say that it is their properties which are separated by commas, and that each property is written as a property name followed by a colon, and then that property’s value.

1 Like

Hi @lfsvamaral,

Nice answers :ok_hand:

Just one comment…

Yes, that’s correct if it’s an expression placed between the square brackets e.g.  array[array.length - 1 ]

Square brackets are also used with property names which are:

  • not valid variable names:
    e.g. object["First Name"] (quotes needed)
    including numbers e.g. array[5] (no quotes needed)

  • valid variable names, but expressed as strings:
    e.g. array["length"]

And, in addition, square brackets are used with variable or parameter names that evaluate to property names.

2 Likes

Excellent answers sir, well documented! Please keep them like that :muscle:

Carlos Z.

2 Likes

Hi @matthurd,

Your answers are generally OK :ok_hand:

Just a few comments…

Part 1

Yes… and two key things about properties are that they are name/value pairs, which store information about a value e.g. a string has a length property which stores as its value the number of characters in the string.

Part 2

I don’t fully understand what you mean here, but just to confirm…
The rest parameter is always the last parameter, so there shouldn’t be another parameter after it to get ignored, anyway. It captures all remaining arguments after the initial ones have been allocated to any individual parameters that precede the rest paramter.

The last items you mention are not allowed in objects written 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?
    It requires a data structure to hold multiple values.

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

  3. What are properties in Javascript?
    The expression defines the characteristic of the value.

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

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

  6. What are methods?
    properties that contain functions.

  7. What are objects?
    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)?
    Object can store values of different data types.

  9. How do you define an object?
    create an object 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?
    Object properties can be changed, causing a single object value to have different content at different times.

SECOND PART:

  1. Why can’t you add new properties to a string variable?
    String is immutable and can’t be changed.

  2. What are rest parameters?
    Rest parameters are parameters that are bound to an array containing all further arguments.

  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?
    Serialisation is to convert data into a flat description. A use case of serialisation of data is JSON.

  5. What is JSON?
    JSON stands for JavaScript Object Notaion. 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?
    in JSON, all property names have to be surrounded by double quotes, and only simple data expressions are allowed, no function calls, bindings , or anything that involves actual computation, comments are not allowed in JSON.

1 Like

Thank you for the valuable insights!!!

1 Like
  1. The need for storing more complex, multi valued variables.

  2. Arrays.

  3. Its a way to access specific properties in a value.

  4. Null and unidentified

  5. with a dot after our value name or with square brackets
    value.property or value["property"]

  6. Methods are properties that contain functions.

  7. Objects are collections of properties.

  8. Creating values that have many different properties and can hold different datatypes.
    9.With a value name followed by braces, inside comes the properties and their description.

  9. the properties of Objects can be changed.

  10. Value types strings, numbers and booleans are immutable.

  11. They use any number of arguments in a function.

  12. Its a conversion of data making it more simple. When we have complex data we can compress it and use only the serialisation of it, making writing code faster, simpler and more easy to read.

  13. A serialisation format which stores different functions, objects etc.

  14. Quite similar, except properties always have to be written between quotation marks and only simple data expressions are allowed

1 Like
  1. He wants to have each entry store two different values so that its more organized.

  2. You can use objects and arrays.

  3. Properties are expressions that can access the property of JavaScript values.

  4. Null and Undefined.

  5. You can use either the dot method or the bracket method.

  6. Properties that contain functions, like the .push or .pop methods.

  7. They are arbitrary collections of properties.

  8. Objects can link different value types together.

  9. You use brackets to hold the information and then have the named properties inside the brackets separated by a comma.

  10. You can change the properties of an object causing a single object value to have different content at different times.

Section 2

  1. The string type is not an object and therefore has no way to change its properties, other than the built in one like: indexOf, length, etc.

  2. Rest parameters contains all the additional arguments and is bound to an array.

  3. N/A

  4. To Serialize something means to convert it into a flat description. It is primarily used to save and/or send your data.

  5. JavaScript Object Notation, JSON, is a format used for serialization in data storage.

  6. In JSON all the property names are surrounded by double quotes, as well as only allowing simple data expressions. No computation or comments.

1 Like
  1. A variable type stores sequences of value in the data structures making it easier to be found is data sets such as arrays.
  2. Arrays can be used.
  3. Used to access properties of some value.
  4. Null and undefined.
  5. “myString.length” is used to get the length of the string and “Math.max” for obtaining the maximum function.
  6. They are properties than contain functions. For example a string and an array object contain various properties.
  7. A collection of random properties.
  8. Objects are capable of holding/storing different data types.
  9. An object is defined by using braces {} around it. Properties inside the curly brackets are separated by commas, colon and value. For example, let human = {name: “Joh”, age: “27”, sex: “male”};
  10. Objects properties can be changed in JS. Their mutability makes them different from strings, numbers, and booleans which are immutable.

SECOND PART

  1. They can’t be changed, they are immutable.
  2. Accepts any arguments and locates the parameters on an array when called. For example, function ("…"){}
  3. Serialisation converts different data structures that are stored and used over the network - flatten the description of the data.
  4. Javascript Object Notation format is used for data storage and communication on the web.
  5. In JSON properties are inside double quotes only in simple expression. There are no bindings, functions, computations, and does not allow comments.
1 Like

Answers First Part

  1. Being able to easily store lots of information within one single “box/entity”.
  2. Objects and arrays.
  3. Properties are characteristics/possessions/things that values have. Comparing it to myself, my properties would be hair colour, eye colour, height, weight etc…
  4. Null and undefined.
  5. value.property or value[property]
  6. Methods are properties that do things (properties that have a function…function). Comparing it to myself my methods are walking, laughing, eating, running etc…
  7. Objects are a collection of properties stored within one variable.
  8. We can store lots of information within a single entity and this information, unlike numbers, strings and booleans, can be changed.
  9. An object is a variable that contains multiple properties.
  10. They are mutable. In other words, their properties can be changed.

Second Part

  1. Because string values aren’t objects and thus don’t contain properties per se. So if you try and add a property it just won’t get recognised by the string, because it doesn’t know what it is.
  2. Rest parameters (…) are used to allow any number of arguments in an array.
    3.Skipped
  3. It’s a form of translating/converting data into a form that can be sent/transmitted from one machine to another.
  4. JSON is such a serialisation format for JavaScript, as well as other languages, used on the web.
  5. All properties need to be put within double quotes (""); there are no comments in JSON; and no computing/evaluation is allowed (so no functions).
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 introduces Basic Data Structures, which allows us to build more complex structures with the help of Objects and Arrays, allowing us to keep multiple values together in the same “bag”.

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

Objects and Arrays.

  1. What are properties in Javascript?

Properties are similar to variables but within an object they hold a value associated with the object.

  1. Which values do not have properties?

Null and Undefined

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

By using dots and square brackets. value.property and value["property"]

  1. What are methods?

Methods are properties which hold a function as its value.

  1. What are objects?

Objects are arbitrary collections of properties.

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

Object values can be modified unlike previously studied data types, namely boolean, numbers, strings, null or undefined which are immutable. Objects work differently since you can change their properties, causing them to have different values at different times.

  1. How do you define an object?

One can create an object by using curly braces " { }" and then adding a list of properties inside, each of them holding their corresponding value. Each property should be separated by a comma and a colon should be in between the property name and its content.

As so:

var Object = { 
       propertyName_1: content_1 ,

       propertyName_2: content_2 ,

      ... ,
      
      propertyName_n: content_n
};
  1. What can you say about the mutability of Javascript objects?

Mutability is the ability that a certain data type has to change its value. In JavaScript data types such as Boolean, Strings and Numbers are immutable, its value cannot be change even though they can be combined and also new values can be derived from them but it is impossible to change it. Whilst with Objects it is certainly possible, they can change the values of their properties according to the conditions given.

SECOND PART:

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

Because properties belong solely to objects and also due to the immutability of Strings.

  1. What are rest parameters?

It is a parameter that for a given Array, holds every single argument. If there are other parameters to either side of it, the rest parameter will take only the arguments in between.

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

However, interesting to read, and helps you understand a bit more the concept of correlation which I feel it might help in understanding all those cryptic data structures.

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

Serialisation converts Data into flat description by storing objects and arrays in the computer’s memory as sequences of bits holding the addresses. It allows you to save data in a file for later or send it to another computer over the network

  1. What is JSON?

A popular serialization format called JavaScriptObjectNotation. It is widely used as a data storage and communication format on the Web, even in languages other than JavaScript.

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

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?
    The problem is storing multiple data, as string and integers can hold only a single type of data. We need a data structure to store multiple values.

  2. What variable type can be used in order to solve the problem of storing multiple values?
    JS provides a data type for storing multiples values: an ARRAY

  3. What are properties in Javascript?
    They are expressions that access a property of a value or an object.

  4. Which values do not have properties?
    The exceptions are the values Null and Undefined

  5. How can we access properties in a value (two ways)?
    The two ways to access properties on values are with a dot . and square braquets [ ]

  6. What are methods?
    They are properties that contain functions. These special functions only work on the value they belong to.

  7. What are objects?
    They 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)?
    They hold multiple data types.

  9. How do you define an object?
    let anObject = {left: 1, right: 2};

  • console.log(anObject.left);*
  1. What can you say about the mutability of Javascript objects?
    That it is possible to change the properties of an object, so this object can have different values at different times

SECOND PART:

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

  2. What are rest parameters?
    A function can accept any number of arguments, when we call that function, the rest parameter is bound to an array containing all further arguments. To write it we put 3 dots before the last parameter. For Example

let numbers = [7, 9, 2];
console.log(max(…numbers));
// 9

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

  2. What is serialisation and what is a use case of serialisation of data?
    Serialisation is to convert data that is stored in the computer’s memory into a flat description. This allows us to storage data and/or to transfer data to another computer on the WEB.

  3. What is JSON?
    JavaScript Object Notation, is a popular serialization format

  4. What are the differences between JSON and the way programmers write objects in plain Javascript?
    All property names need to be surrounded by double quotes, and only simple data expressions are allowed (no functions calls, bindings, or anything that involves 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?
    Jacques need to store and use multiple values.

  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?
    They are characteristics of a value.

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

  5. How can we access properties in a value (two ways)?
    string.length and string["length]

  6. What are methods?
    properties that contain functions.

  7. What are objects?
    arbitrary collections of properties.

  8. What problem do objects solve that cannot be solved with other value types we’ve learned so far (such as integer, string, array, boolean etc)?
    Objects allow us to group a group of diffrent values and variable types into one object that can be used in an array

  9. How do you define an object?
    defining a variable and using braces and having values separated by commas inside those braces

  10. What can you say about the mutability of Javascript objects?
    Object values can be modified throughout the program.

SECOND PART:

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

  2. What are rest parameters?
    three dots before the last parameter which spreads the argument into an array.

  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?
    When data is converted into flat data for sending over a network.

  5. What is JSON?
    Javascript object notation used for data storage and communication on the web.

  6. What are the differences between JSON and the way programmers write objects in plain Javascript?
    all property names must be surrounded in double quotes, only simple expressions are allowed in JSON. There are no functions, bindings, comments, or computations.

1 Like

Excellent answers sir, well documented! Please keep them like that :muscle:

Carlos Z.

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?

-Unlike variables that permit data storage in rows it is more substantial to create a data structure.

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

- Array variable can be used.

3. What are properties in JavaScript ?

- Properties are values linked with a JS object and an object is a compilation of properties, the may be read only, changed, added and deleted.

4. Which values do not have properties?

- Not all values contain properties. Null and Undefined are the two JS values that you get an exception when you try to read a property.

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

- There are two ways to access properties:

1.Dot notation: person . firstName = Ivan

2.Bracket notation: person [“ lastName ”] = onTech

6. What are methods?

- Methods are actions performed on objects, they are properties containing values.

7. What are objects?

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

- Object property stores a literal value and can hold many different variable types.

9. How do you define an object?

- You define and object by using braces: let object1 = {value: 10};

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

- Objects are mutable meaning you may change properties.

SECOND PART:

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

- Strings are immutable, you can´t add properties.

2. What are rest parameters?

- Rest parameters lets us represent many arguments as an array.

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

- Serialisation is transforming data into a suitable format to transfer over a network.

4. What is JSON?

- JavaScript Object Notation is a compressed format of storing data, making it easier to transport over web pages, servers, etc.

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

- JavaScript objects and JSON objects are different, in JSON no bindings, function calls or actual computation is allowed.

1 Like