Data Structures (Arrays and Objects) - Reading Assignment

FIRST PART
1. Instead of storing a single data, our friend from the story needs to store various data as to understand his condition. For this purpose, the best would be to build a data structure that stores all this information.
2. For storing multiple value we can use Arrays.
3. With certain expressions we can access the property of some value.
4. Only the values ‘null’ and ‘undefined’ will return an error.
5. We can either access properties through the dot annotation or through square brackets, but the result won’t be necessarily the same.
6. Methods are properties that contain functions.
7. Objects are arbitrary collections of properties.
8. Objects can store as many different datatypes as we need.
9. Objects are like boxes, identified by curly braces, that can have inside various properties and values that are innate to that object (although these can be modified, new can be added and even deleted).
10. Mutability in objects let us modify their properties and like that we can have a single object having diferent content at different times.
SECOND PART
1. We learned that strings are immutable: there is no way that we can change a string of ‘airplane’ to store some different property. The text inside the string value won’t be changed by any code.
2. They allow a function to accept any number of arguments.
3. Serialization is converting data stored in mamery into a flat description. It is used to save or share data over a network.
4. JavaScript Object Notation - the most popular serialization format used as a data storage and comunication format on the Web.
5. There are some 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, and no comments)

1 Like
  1. Read the sub-chapter called The weresquirrel. What problems does this chapter introduce that cannot be solved with variable types such as strings or integers?
    Ans: Variable types such as strings and integers are not very effective at storing sequences of values. What is needed for Jacques is a data structure that is capable
    of storing multiple values and datatypes in order to keep all of the information organized.

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

  3. What are properties in Javascript?
    Ans: Properties define some characteristic about the values in a data structure, such as the length of an array or the maximum function in a Math object.

  4. Which values do not have properties?
    Ans: Null and undefined which are in effect “nonvalues.”

  5. How can we access properties in a value (two ways)?
    Ans: 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. The difference is in how x is interpreted.
    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. Whereas value.x fetches the property of value named
    “x”, value[x] tries to evaluate the expression x and uses the result, converted
    to a string, as the property name.

  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. One way to
    create an object is by using braces as an expression.

  8. What problem do objects solve that cannot be solved with other value types we’ve learned so far (such as integer, string, array, boolean etc)?
    Ans: Objects are able to hold as many different datatypes as we need and organize them efficiently. We can use an array of objects to solve the “WereSquirrel” problem.

  9. How do you define an object?
    Ans: Braces are used to create objects. Properties inside the braces are separated by commas. Each property is named, followed by a colon and a value.

  10. What can you say about the mutability of Javascript objects?
    Ans: Values such as numbers, strings, and booleans are all immutable whereas object values can be modified. Objects work differently. You can change their properties,
    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?
    Ans: Values of type string are not objects, they are immutable and cannot be changed.

  2. What are rest parameters?
    Ans: Rest parameters are bound to an array which contains all further arguments. This allows a function to allow any number of arguments. To add a rest parameter, you use three dots before the function’s last parameter.

  3. What is serialisation and what is a use case of serialisation of data?
    Ans: Serialization of data entails converting the data into a flat description. Since objects and
    arrays are stored in the computer’s memory as sequences of bits holding the addresses—the place in memory—of their contents, you have to somehow convert these tangles of memory addresses to a description that can be stored or sent and that is where serialization of data is helpful.

  4. What is JSON?
    Ans: 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

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

Objects are data structures that allow us build ore complex data structures. Strings, Booleans, and numbers are the atoms that data structures are built n.

  1. What variable type can be used in order to solve the problem of storing multiple values?
    Arrays and objects are the data structures used to store multiple values in aa variable.

  2. What are properties in Javascript?
    Properties are characteristics of values in Javascript. Or values associated with a Javascript object.

  3. Which values do not have properties?
    Null and undefined are values that DO NOT have properties associated with them.

  4. How can we access properties in a value (two ways)?
    The two ways to access properties are ‘dot notation’ ( array.value) and ‘brackets’ ( array[i]; )

  5. What are methods?
    Methods are properties that hold functions as values.

  6. What are objects?
    Objects are data structures that hold ‘lists’ or properties with corresponding values. Or Objects allow to arbitrarily collect values together.

  7. 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)?
    Allow for immutability, or change values w/o having to add to subtract variables.

Objects allow you to collect and group data together.

  1. How do you define an object?
    1- Create a binding and name it. 2- Use curly braces at the beginning and end. 3- List properties inside the braces, separate them by commas. 4- Each property has a name, separated by a colon: and a value.

  2. What can you say about the mutability of Javascript objects?
    Unlike strings, boolean, and numbers objects values are immutable and can be changed w/o having to add or subtract the value of bindings to achieve a new value which will be stored in a new binding or variable itself.

Section 2-----

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

  2. What are rest parameters?
    Allow me to represent an indefinite amount of arguments as an array.

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

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

  5. What is JSON?
    Javascript Object Notation is used to send send arrays & objects across a network by first converting them into a string vis JSON.stringfy and the JASON.parse to convert back to an object.

  6. What are the differences between JSON and the way programmers write objects in plain Javascript?
    JSON’s names must be surrounded by double quotes, only simple data expressions are allowed, np functions, calls, bindings, or anything that computes. Comments are also not allowed.

1 Like
  1. This subchapter introduces objects and arrays that group values of different qualities together that strings/integers alone cant do.

  2. strings are a variable that allows us to store multiple values of the same data set.

  3. properties allow coders to access values within bindings.

  4. null and undefined.

  5. with a dot or bracket.

  6. Methods are properties that hold function values

  7. objects allow us to store arbitrary properties with a square bracket.

  8. They allow us to store integers, strings and boolean values at the same time that cant be done with specific variables alone.

  9. objects grasp values that can be held by other objects.

  10. Objects are not immutable, in that you can have an object storing to different values at different times.

  11. string values are immutable unlike objects, once a a string variable is created, its impossible to change.

  12. they denote (…) after the last parameter and are bound to every argument after.

  13. Serialization allows us to encode stored javascript data and compress it into a string for export.

  14. JSON is the serialization program of javascript.

  15. JSON is the simplified version of the code and does not allow computation expressions and exterior comments.

1 Like

PART ONE
1.- The problem that weresquirrel introduces that cannot be solved using bindings such as strings and integers is keeping log of multiple data or entries.
2.- Multiple values can be stored in an array.
3.- Properties are information or data available for a data structure or value in JavaScript.
4.- Null and undefined are the only values in JavaScript that do not have properties.
5.- Properties can be accessed as follow: value.Property; and can also be accessed with brackets as follow: value[“Property”].
6.- A method is a property that contains a function. Methods can take arguments.
7.- An object is a data structure that collects arbitrary properties.
8.- Objects can store multiple properties and are also mutable.
9.- An object for me is a collection of properties. For example a pet object can be: { animal: cat, color: brown, age: 9, aggresive: false}
10. Objects in JavaScript are mutable data.

SECOND PART:
1.- You cannot add a property to values like string, number or boolean because they are not objects in JavaScript; they are immutable.
2.- Rest parameters allows you to pass any number of arguments as an array.
4.- Serialization of data is the process of converting your data in a format that is flat.
5.- JSON is JavaScript Object Notation and it is a serialize form of an object to transfer or communicate.
6.- JSON contains double quotes for all parameters except simple numbers and booleans.

Hi Friends && Coders

I am trying to Create the following Array from an Empty array

journal1 =
{
Monday: {events : [“work”, “touched tree”, “pizza”, “running”,“television”"], squirrel : false},
Tuesday : {events : [“work”, “ice cream”, “cauliflower”, “lasagna”,“touched tree”, “brushed teeth”], squirrel : false},
Wednesday : {events : [“weekend”, “cycling”, “break”, “peanuts”,“beer”], squirrel : true}
}
];

Now to create the above array i wrote the following Code:

**Can someone please advise me where i am going wrong, i have been trying to solve the problem since hours, but unfortunately no success yet, i shall be extremely grateful **

1 Like

Hi Friends && Coders

I am trying to Create the following Array from an Empty array

journal1 =
{
Monday: {events : [“work”, “touched tree”, “pizza”, “running”,“television”"], squirrel : false},
Tuesday : {events : [“work”, “ice cream”, “cauliflower”, “lasagna”,“touched tree”, “brushed teeth”], squirrel : false},
Wednesday : {events : [“weekend”, “cycling”, “break”, “peanuts”,“beer”], squirrel : true}
}
];

Now to create the above array i wrote the following Code:
Hi Friends && Coders

I am trying to Create the following Array from an Empty array

journal1 =
{
Monday: {events : [“work”, “touched tree”, “pizza”, “running”,“television”"], squirrel : false},
Tuesday : {events : [“work”, “ice cream”, “cauliflower”, “lasagna”,“touched tree”, “brushed teeth”], squirrel : false},
Wednesday : {events : [“weekend”, “cycling”, “break”, “peanuts”,“beer”], squirrel : true}
}
];

Now to create the above array i wrote the following Code:

**Can someone please advise me where i am going wrong, i have been trying to solve the problem since hours, but unfortunately no success yet, i shall be extremely grateful **

1 Like
  1. Variable types such as Integers and Strings cannot hold Multiple Data types/ values.
  2. Objects and Arrays.
  3. 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. Null and Undefined.
  5. Example of two ways ==> Array.length or array[length]
  6. Methods are properties that hold function values.
  7. Objects are data structures with Multiple values that are capable of holding an arbritary collection of properties.
  8. Objects are special because they are able to hold many and many kinds of data types.
  9. Objects are always within braces {};
  10. Objects are mutable in Nature.

Second part :slight_smile:

  1. String is primitive in nature and can only hold a single immutable value.
  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.
  4. JavaScript Object Notation is a serialisation format widely used for data storage and communication.
  5. Both value names and Properties need to be surrounded in double quotes and only simple data expressions are allowed. So no function calls, bindings, or anything that involves actual computation. Also, comments are not allowed in JSON.
1 Like

Homework on Data Structures(Arrays and Objects) - Questions November 22, 2020

First part-

  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?
    Variables retain one type of data. Data structures allow the storage of multiple data types.

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

  3. What are properties in Javascript?
    Properties are the length and data type of a Javascript value.

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

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

  6. What are methods?
    Properties that contain functions are methods.

  7. What are objects?
    Objects cotain a collection of properties. They’re created using braces holding a list of data structure values with 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 hold a variety of different types of data.

  9. How do you define an object?
    Objects are similar to variables that hold different values.

  10. What can you say about the mutability of Javascript objects?
    Values in a object can be changed.

Second part-

  1. Why can’t you add new properties to a string variable?
    Strings are immutable, because they hold specific data that defince the function of the code.

  2. What are rest parameters?
    Rest parameters allow a function to use any type of value as an argument.

  3. What is serialisation and what is a use case of serialisation of data?
    Seriallisation is a means of converting data into a flat description.

  4. What is JSON?
    JSON is a format to serialize data, use as data storage and a variety of communication formats.

  5. What are the differences between JSON and the way programmers write objects in plain Javascript?
    All property names must be surrounded by double quotes and only simple date expressions are allowed
    Functions, bindings, and comments are used in JSON.

-Hector A. Martinez

1 Like

Think about the following questions:

  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 as strings and integers can only hold a single type of data, which makes them all immutable.
    
  2. What variable type can be used to solve the problem of storing multiple values?

      	[ARRAYS] is a good example.
    
  3. What are properties in Javascript?

         Properties are a way for us to get a certain meta-information about an object; variables and arrays are types that we can do to them.
    
  4. Which values do not have properties?

       	The exceptions are null and undefined. When trying to access property on one of these nonvalues, then you will get an error.
    
  5. How can we access properties in a value (two ways)?

      The two main ways to access properties in JavaScript are with a dot. and with
      square brackets[]
    
  6. What are methods?

      Methods are functions that belong to the object that allows us for 	to do something to the data inside an object, such as a variables or arrays.
    
  7. What are objects?

     You can see objects as a type of blueprint where we put together similar properties and methods inside an object in order to group together and organize our code in a much better way than using variables and fucntions.
    
  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)?

        An object can hold different datatypes.
    
  9. How do you define an object?

                // This is the long way of creating a object, but there is a more 	simpler way.
    
                  let person = new Object();
    
                  person.name = "David"
                  person.eyeColor = "Brown"
                  person.age = 35;
                  person.updateAge = function() {
                    return ++person.age;
                  }
    
    
                  console.log(person.age);
                  person.updateAge();
                  conosle.log(person.age);
    
    
                  // a simpler way
    
                  let person = {
                name: "David",
                eyeColor: "Brown",
                age: 35,
                updateAge: function(){
                  return ++person.age;
                }
              }
    
              console.log(person);
    
  10. What can you say about the mutability of Javascript objects?

    In JavaScript, only objects and arrays are mutable, not primitive values. …
    A mutable object is an object whose state can be modified after it is created. Immutables are the objects whose state cannot be changed once the object is created.
    Strings and Numbers are Immutable

SECOND PART

  1. Why can’t you add new properties to a string variable?
    Becouse they are not Objects and such values are immutable and cannot be changed.

  2. What are rest parameters?

          Rest parameter is an improved way to handle function parameter, allowing us to more easily handle various input as parameters in a function.
          The rest parameter syntax allows us to represent an indefinite number of arguments as an array.
    
  3. What is serialisation and what is a use case of serialisation of data?

       Serialization is the process of converting an object into a stream of bytes to store the object or transmit it to memory, a database,
       or a file. Its main purpose is to save the state of an object in order to be able to recreate it when needed.
    
  4. What is JSON?

       JSON is a standard text-based format for representing structured data based on JavaScript object syntax
       It is commonly used for transmits data in web applications sending some data from the server to the client so that it can be displayed on a web page.
    
    • Skip
  5. What are the differences between JSON and the way programmers write objects in plain Javascript?

       Diffrence between the JSON and JAVASCRIPT is that there are six data types that JSON supports are the following:
    
    
       Array
       Boolean
       Null
       Number
       Object
       String
       But, JavaScript Object support any data type that JavaScript (language) itself supports as a value of its properties.
    
       JavaScript Supported Data types below:
    
       Boolean
       Null
       Undefined
       Number
       BigInt
       String
       Symbol
       Object
    
    
       # JSON doesn’t support undefined but, JavaScript Object does. Instead of undefined JSON supports null.
    
       # You can assign a function as a value in JavaScript Object but not in JSON.
    
       # You can’t comment inside JSON. It just doesn’t support comment, it must be all JSON data, but you can comment inside JavaScript Object.
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?
    We have the problem that we need to store more than just one value and this cannot be done with strings or integers.

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

  3. What are properties in Javascript?
    Properties are expressions that access a certain information of some value.

  4. Which values do not have properties?
    The only values with no properties are “null” and “undefined”.

  5. How can we access properties in a value (two ways)?
    You can access properties by either by using a dot (“value.x”) or brackets (“value[x]”).

  6. What are methods?
    Methods are properties of a value that contain functions.

  7. What are objects?
    Objects are data structures that can contain up to a 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 are mutable which means that you can modify or rather update values.

  9. How do you define an object?
    You define objects by using braces as an expression followed by a list of properties. The properties all have a name followed by a colon and a certain value, for example:

let TestObject = {
fun = false;
event = [“waiting in line”]
};

  1. What can you say about the mutability of Javascript objects?
    Objects can be modified whereas strings, numbers, booleans etc. cannot.

SECOND PART:

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

  2. What are rest parameters?
    Rest parameters make it possible to accept any number of arguments without specifying about the exact amoung.

  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?
    Serialization means converting data structure into a so called flat description which allows you to store or send it.

  5. What is JSON?
    JSON stands for JavaScript Object Notation and is a popular serialization format.

  6. What are the differences between JSON and the way programmers write objects in plain Javascript?
    JSON doesn’t allow comments and everything is put between double quotes except basic data types like integers or booleans.

1 Like
  1. The sub-chapter (The Weresquirrel) has introduced a variety of events, which facilitates a complexity of information with different concepts, uncertainties, solutions, transformational triggers, and multiple values of all types. These problems cannot be solved with variable types such as strings or integers.

  2. The data type “arrays” are used to solve the problem of storing multiple values. Arrays are a list of values between square brackets, separated by commas. let num = [2, 4, 6, 8, 10, 12];

  3. Properties are expressions that access a property of some value.

  4. Null and undefined are nonvalues which don’t have properties, if you try to access a property on them, you get an error. // TypeError: null has no properties

  5. Properties are accessed by using a dot in some instance value.x and square brackets in other instances value[x].

  6. Methods are functions that live on properties and act on the value they are properties of. Actually, commands which are used on values to manipulate them. The push method adds values to the end of an array, Etc;.

  7. Objects are a collection of attribute-related constants and functions. Objects tend to use names as their properties and store a fixed set of them.

  8. Objects are mutable and can be changed, but the primitives are immutable and cannot be changed.

  9. Defining an object: Objects are an unordered collection of related data, of primitive or reference types, in the form of “key: value” pairs. It’s a structure which allows us to group values, including other objects, to build more complex structures.

  10. Javascript objects properties can be changed, causing a single object value to have different content at different times. It’s mutability is versatile within its values.

Second Part–:

  1. New properties cannot be added to string variables because strings have built-in properties and specific related methods, as they are immutable the properties do not stick, therefore not permanent.

  2. Rest parameters are substitutes for a function, which accepts any number of arguments.

  3. skip.

  4. Serialization is a conversion of tangled memory addresses, which can be used for serializing (flattening for ease of transportation) the data.

  5. JSON is a serialization format. A data storage and communication format on the Web.

  6. Difference in using JSON and writing objects: JSON has a few restrictions wherein all property names have to be surrounded by double quotes. In using JSON only simple data structures are allowed and nothing involving computational computing. Comments are not allowed in JSON. All other functionalities allowed in writing objects are allowed. Therefore JSON and Objects are similar except for the few restrictions above.

1 Like

i will answer these questions after i finish reading the chapter. for now i have a basic question that i hope is appropriate for this thread.

when a function console.log’s information, is that information stored in the browser for other functions to access?

  1. He need a data structure for all the information.
    2)Array
  2. Properties are characteristic data of our study’s case.
  3. null, undefined
    5)value.property, value[property]
    6)Properties that contain function
  4. They are a list of value combined in a single one and put in an array
    8)Object can store a multiple type of value at the same time.
    9)It is a list of characteristic, value, useful for define a list of different object.
    10)It make object very useful for changing data during the run.

SECOND PART:
1)String are immutable. You can only substitute it with another one, not changing it.
2) Rest parameters are bound to an array,which contains all further arguments. This allows functions to allow any number of arguments. To add a rest parameter use three dots before the function’s last parameter.
3)
4)Objects and arrays are stored as bits holding addresses. These objects can be serialized into a data management notation, suitable for digital communications.
5) JavaScript Object Notation. It is widely used as a
data storage and communication format on the Web, even in languages other
than JavaScript
6)Only single expression are allowed in JSON. easier to transfer.

1 Like

Hi @Regis_Brickett, No the information is not accessible. It’s just printed out and not stored anywhere. It’s just a one-time operation.

Hope this clears your doubt.

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 of accessing multiple sets of numbers in a data set.
Variable types like strings and integers can only hold a single type of data.

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

Arrays can hold multiple values that can be easily accessible.

3. What are properties in Javascript?

Properties are hidden capabilities in a value that one can call for example .length and .color.

4. Which values do not have properties?

null and undefined.

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

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

6. What are methods?

Methods are a set of functions that manipulates or call out data from arrays.

7. What are objects?

Objects are data structures that are capable of containing an arbitrary collection of properties.

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

Objects are special as they are able to hold as many different datatypes as we need.

9. How do you define an object?

Objects are a set of values inside [ brackets ] separated by a , comma.

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.

SECOND PART:

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

Strings are immutable. They do not store new properties.

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 serialization and what is a use case of serialization of data?

Serialization is used in JSON to compact data. JSON is used as a data storage and communication format on the web.
Serialization means it is converted into a flat description.

4. What is JSON?

JSON is a data storage and communication format on the web.

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

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

PART ONE
1.- The problem that weresquirrel introduces that cannot be solved using bindings such as strings and integers is keeping log of multiple data or entries.
2.- Multiple values can be stored in an array.
3.- Properties are information or data available for a data structure or value in JavaScript.
4.- Null and undefined are the only values in JavaScript that do not have properties.
5.- Properties can be accessed as follow: value.Property ; and can also be accessed with brackets as follow: value[“Property”] .
6.- A method is a property that contains a function. Methods can take arguments.
7.- An object is a data structure that collects arbitrary properties.
8.- Objects can store multiple properties and are also mutable.
9.- An object for me is a collection of properties. For example a pet object can be: { animal: cat, color: brown, age: 9, aggresive: false}
10. Objects in JavaScript are mutable data.

SECOND PART:
1.- You cannot add a property to values like string, number or boolean because they are not objects in JavaScript; they are immutable.
2.- Rest parameters allows you to pass any number of arguments as an array.
4.- Serialization of data is the process of converting your data in a format that is flat.
5.- JSON is JavaScript Object Notation and it is a serialize form of an object to transfer or communicate.
6.- JSON contains double quotes for all parameters except simple numbers and booleans.

1 Like
  1. storing multiple values, since it would be hard to retrieve the data inside them.

  2. Arrays are the best solution to this problem because theyre spefically made for storing several values, and data is easily accesible
    when it is stored inside an array.

  3. Properties are expressions used to get information about a value, because almost every value has properties, you can check string lengths
    and create loops based on that information, or based on any property, properties are a really powerful tool.

  4. null and undefined dont have properties.

  5. we can acces properties in two ways, using a dot and using brackets.

  6. Methods are properties that contain functions.

  7. An object is a value that contains a list a of properties.

9.I define an object as a book where you write things everytime you need to, but this one is a very important book that you wanto
keep upddated to keep your program running the way you want it to run.

  1. I think that mutability is a very useful property, because i will allow us to keep our code changing, integrating new data, i suspect
    that is thanks to this mutability that much of the programs and webpages that we visit everyday, dont need to be constantly updated by a person,
    but they update themselves thanks to object’s mutability, getting fed new data everyday. <–(i am prrobably wrong in this assumption)

1.Because JavaScript don’t give strings tthe same permissions that it gives to objects, so it wont let us add new values to strings.

2.This one was hard for me to understand, but seems to me thtat a rest parameter allows us to set any amount of values as parameters for our function or array.

4.Serialization is the act of giving a description to a chunk of data, where is it used, hmm im pretty sure just about anywhere some sort of
serialization is needed in order to keep data organized, i use serialization in my pc everyday, otherwise i wouldnt know what is what and it would be a mess.

5.Json is javascripts serialization format.

6.JSon is a more simple format, where you cannot really create programs or anything it is just meant for serialization.

1 Like

These answers are really key. One of the biggest things I am learning with javascript is how it different from Python in scope. Javascript jumps around, where python you really move top to bottom. I will definitely want to practice javascript more in depth with parent/child functions.

Luckily data types/objects are similar to python.

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

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.

1 Like
  1. the wersquirrel introduces a large dataset. the numbers of variables that you would have to create to represent each event would be unruly to work with. you also have another boolean variable tied to each event.

  2. arrays can be used to store multiple values in one variable.

  3. properties are values that are stored within a property name. i like to think of it as a physical object. those physical objects have properties. a ball is round. round is a property. you could name that property “shape” … shape: round, elements in an array are also properties. the property names for each element is their index position.

  4. null and undefined do not have properties.

  5. you can access properties with dot or bracket notation.

  6. a method is a property that contains a function that can alter the value of the property it is tied to.

  7. objects are values that consist of arbitrary properties.

  8. when you create an object you can add many values types in the same place: number, string, boolean. you can much more easily access the values you desire in that object regardless of the value type.

  9. you can define an object like a variable. var x = {object}

  10. it is impossible to change the value of a string, number, or boolean. they are immutable. the values in an object can however be changed.

  11. you cant add new properties to a string value because string values are immutable.

  12. rest parameters allow a fucntion to accept any number of arguments for the rest parameter. the function will include any arguments after but not before the rest parameter

  13. serialisation allows us to transmit data contained in an object or array without sending the whole computer memory. it takes a complex object or array and flattens it. this is needed because properties dont actually store values. they only store the location of the values in the computers memory. serialisation is useful in accessing data at a later time or transmitting data to another location. when the serialized data is received it is then deserialized to recreate the object or array.

  14. JSON is a serialisation format that is used as a data storage and communication format on the web. it is accepted by languages other than javascript.

  15. in JSON all properties are in double quotes. also only simple expressions are allowed. you cannot include function calls or bindings in JSON format. it essentially can only be used to store immutable values.

1 Like