Data Structures (Arrays and Objects) - Reading Assignment

  1. In JavaScript, there are two types of data: primitive and reference types. With primitive types, the data is stored directly in the location that the variable accesses it’s stored on the stack. When you access primitive data you access it by its actual value. Reference types are objects that are accessed by reference.
    So the data isn’t actually stored in the variable it’s stored on what’s called the heap which has to
    do with dynamically allocated memory.
    There are six primitive data types: String, Number.Boolean, Null, Undefined, Symbols.
    Reference types:Arrays, Object literals, Functions, Dates ,etc.
    Arrays allow us to store multiple values in one variable.That’s why Jaques cannot use primitive data types. He needs a data structure to store multiple values.
  2. Arrays
  3. Properties are ways for us to get certain information about an object.
  4. Null and Undefined.
  5. The two main ways to access properties are: -with a dot ex: value.x
    -with square brackets ex: value[x]
  6. Methods are functions that belong to the object that allows us to do something to the data inside the object.
  7. An object is a collection of properties, and a property is an association between a name (or key) and a value. A property’s value can be a function, in which case the property is known as a method.
  8. We can access and store multiple values in one place.
  9. An object is a collection of properties.
  10. Mutable is a type of variable that can be changed. In JavaScript, only objects and arrays are mutable, not primitive data types(values). You can make a variable name point to a new value, but the previous value is still held in memory.

PART TWO

  1. A string value is immutable.
  2. The rest parameter is an improved way to handle function parameters, allowing us to more easily handle various inputs as parameters in a function. The rest parameter syntax allows us to represent an indefinite number of arguments as an array.
  3. Serialization is converting the data into a flat description. You can use serialization to transfer data to another computer over the network.
  4. JSON= JavaScript Object Nation, a popular serialization format, used as data storage and communication format on the web.
  5. JSON looks similar to JavaScript’s way of writing arrays and objects, but it has some restrictions: property names have to be in quotes, simple data expressions are allowed(no function calls, bindings, anything that involves computation). No comments are allowed.
2 Likes

First part: the weresquirrel

  1. Jacques would not be able to distinguish between his logged activities because each activity log would be just one long string of text whose properties are impossible to change or access independently.

  2. array

  3. they are characteristics or functions possessed by values.

  4. null and undefined

  5. using dot or square brackets

  6. properties that contain functions

  7. Objects are values that contain an arbitrary collection of properties.

  8. Objects have the flexility that other values don’t in that they are very customizable, flexible, and accessible.

  9. An object is a variable that can contain as many properties as you’d like.

  10. Values such as numbers, strings, and booleans are immutable - they cannot be changed once created. E. g., a “blue car” string can never become a “red car.” Objects, on the other hand, possess multiple properties that can be individually changed, which makes objects mutable values.

2 Likes
  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 introduce a data structure that is capable of storing multiple values.
  2. What variable type can be used in order to solve the problem of storing multiple values?
    JavaScript provides a data type specifically for storing sequences of values. It is called an array and is written as a list of values between square brackets, separated by commas.
  3. What are properties in Javascript?
    These are expressions that access a property of some value.
  4. Which values do not have properties?
    The exceptions are null and undefined.
  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?
    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?
    An object is an arbitrary collection of 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 allow us to group several values into a single value
  9. How do you define an object?
    One way to create an object is by using braces as an expression. Inside the braces, there is a list of properties separated by commas. Each property has a name followed by a colon and a value.
  10. What can you say about the mutability of Javascript objects?
    Object values can be modified.

SECOND PART:

  1. Why can’t you add new properties to a string variable?
    Strings are immutable and cannot be changed.
  2. What are rest parameters?
    A rest parameter allows to pass an indefinite number of arguments to a function.
  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 is the process of converting data structures or an object state into a format that can be stored or sent.
  5. What is JSON?
    A popular serialization format is called JSON, 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.
  6. What are the differences between JSON and the way programmers write objects in plain Javascript?
    All property names have to be surrounded by double quotes, and only simple data expressions are allowed. Comments are not allowed in JSON.
2 Likes

Second Part:

  1. because it’s an immutable value. It has built-in properties

  2. it makes it possible to add an array of arguments to be executed by a function

  3. it means converting pieces of data into a flat description. It is useful when eg. saving a piece of code into another device to reuse it later.

  4. it’s a popular serialization format which stands for JavaScript Object Notation. Despite its name, it is also used in languages other than JavaScript.

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

2 Likes
  1. he has to work with many types of data variables beyond just strings and integers.
  2. an array
  3. The elements in an array are stored as the array’s properties
  4. null and undefined
  5. value.property or value[property]
  6. properties that contain functions
  7. collections of properties
  8. object values can be modified, they are mutable
  9. let objectName = [ {events: [“work”, “touched tree”], squirrel: false}, ];
  10. its really useful when working with things like statistics.

  1. they are not objects and are immutable
  2. “…” allows function to recive any number of arguments
  3. done
  4. data being converted to a flat description
  5. JavaScript Object Notation
  6. JSON cant do any computation, so no function calls, bindings, or
    anything that involves actual computation
2 Likes

First Part:

  1. The problems that are introduced with this chapter that cannot be solved with variable types such as strings or integers are that we need to represent more variables in one data structure and strings or integers are only capable holding a single data type.

  2. The variable types that can be used in order to solve the problem of storing multiple values are Arrays and Objects.

  3. Properties in Javascript are expressions that access to the data value.

  4. The values “Null” and “Undefined” do not have properties.

  5. We can access properties in a value via two main ways one with a dot and the other via square brackets. (Example value.X and Value [X]

  6. Methods are properties which hold function values for example Push Method adds values to the end of an Array and Pop Method does the opposite removing the last value in the Array returning it.

  7. Objects are data structures that can hold arbitrary collections of properties. One way to create an object is by using braces as an expression. Inside the braces the list of properties are separated by commas each has a name followed by a colon and value.

  8. The problem that Objects solve that can’t be solved with other value types is that they can be modified they are mutable causing a single object value to have different content at different times whereas other value types such as Boolean, strings, arrays are immutable.

  9. Objects are defined like other variables with the value being a list contained within braces.

  10. Mutability of Javascript objects means that the values they contain can be changed and also changed at different times, whereas other datatypes such as strings, booleans and arrays can’t be modified and always maintain the same values they are immutable.

Second Part:

  1. You can’t add new properties to a string value because they don’t stick as such string values are immutable and can’t be changed.

  2. Rest parameters are used 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. If there are any parameters before it their values aren’t part of that array. Example math.max (… numbers) {

  3. Serialisation is converting data stored memory into a flat description that can be stored or sent. One use case is if you want to save data in a file for later or send it to another computer over the network you have to convert these tangles of memory addresses to a format that can be sent.

  4. JSON is Javascript Object Notation is a popular serialisation format standardly used for data storage and communication format on the web.

  5. The differences between JSON and the way programmers write objects in plain javascript are that all property names have to be surrounded by double quotes and only simple data expressions are allowed. There are no function calls, bindings or anything that involves computation.

What a monster :smiling_imp: of a chapter :sweat_smile:

(and breathe :smiley:)

Lets go, onto the next one :sunglasses: :upside_down_face:

2 Likes

OBJECTS AND ARRAYS

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, we need to log a number of different values and variable types grouped together in meaningful way. A string variable only holds strings, integer only holds integers… they hold a single data type. We need to be able to hold string, integer, Boolean and may be other data types together, to keep the information grouped in a way to help determine what causes the transformation.

What variable type can be used in order to solve the problem of storing multiple values?
Object and then an array can be used to store multiple values of the same object type.

What are properties in Javascript?
Almost all values have properties in JavaScript.

Which values do not have properties?
null
undefined

How can we access properties in a value (two ways)?
Using dot notation or square brackets.
value.x - where x is the literal name of the property eg value.length => length
value[x] - where x is an evaluation of the property name eg where x is the index number value[2] the 3rd item of the array would be used/returned

What are methods?
These are properties that contain functions. A method is referred to as belonging to a value… “toLowerCase is a method of string”.

What are objects?
Values of an object type are arbitrary collections of properties (ie the can be lots of different properties, not just of say string or integer).
To see what properties an object has you can use the Object.keys function which returns a list of strings which give the object’s property names.

What problem do objects solve that cannot be solved with other value types we’ve learned so far (such as integer, string, array, boolean etc)?
Objects can store mutliple data types into a single data structure.

How do you define an object?
In JavaScript they are represented in curly brackets { } and inside the curly brackets there is a list of properties separated by commas.

let exampleObject = {prop1: "car", prop2: "rain", prop3: 7, prop4: true};

  • exampleObject is the Object name
  • {} indicate it is an object type
  • prop1 and prop2 contain strings, but one is for vehicles and the other is for weather
  • prop3 contains integers, representing day of the week
  • prop4 contains a Boolean, to indicate if something happens or not

What can you say about the mutability of Javascript objects?
You can modify the object values. This is different to other data types such as strings, integers and Boolean.
With objects you can have two references to the same object (the same identity) which is different to two objects that contain the same properties (and have their own separate life). You use the == operator to compare objects by identity, with it producing true only if the objects are exactly the same value.

STRINGS AND THEIR PROPERTIES

Why can’t you add new properties to a string variable?
They are immutable and the properties cannot be changed. A string variable has built-in properties only.

What are rest parameters?
This is used when a function needs to accept any number or arguments, it is written using … before the last parameter.
When the function is called the rest parameter is bound to an array containing all further arguments, it is only for that specific parameter.

What is serialisation and what is a use case of serialisation of data?
It is where the data, which is stored in the computer’s memory is converted into a flat description, rather than using the memory addresses of where the data is and other construct information (inner, outer array, binary number for position of inner array etc).
A use case for it would be when you need to save data into a file or send it to another computer over a network.

What is JSON?
It is a serialisation format. Widely used as data storage and communication format on the Web, for JavaScript and other languages.

What are the differences between JSON and the way programmers write objects in plain Javascript?
JSON is more restrictive. Property names have to be surrounded by double quotes, and only simple data expressions are allowed. No function calls, bindings or anything that involves computation. There are also no comments allowed.

I started to read those other bits… WOW… I stopped… even more coffee didn’t help… too much, too soon in that book!! Will go back to it eventually…

2 Likes
  1. the weresquirrel chapter introduces problems that cannot be solved with variable types such as strings, or integers, because Numbers, Booleans, and Strings, have been limited by the fact that they are operating on simple data types. we need something that allows us to group values including other Objects therefore allowing us to build more complex structures.

  2. The variable type that can be used to solve the problem of storing multiple values is called an Array.

  3. Properties in Javascript can be difficult to describe. The two main ways they can be accessed are with a dot(.) or square brackets,( [ ] ). in these two examples there is a difference in how they are interpreted. if for example we have a value.x, and a value[x], they both access a property on value, but not necessarily the same property. The difference is in how x is interpreted. the name after a dot is the literal name of the property whereas, when using square brackets, the expression between the brackets is evaluated to get the property name. Also I will add, that almost all Javascript values have properties, with the exception of two. With this and after reading it a couple of times through it started to make a little more sense to me. I think this is one where as if you just practice using these, it makes more sense than reading them.

  4. The values which do not have properties are Undefined, and Null

  5. we can access values using a dot (.) or calling up some square brackets, [ ]

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

  7. Objects are, arbitrary collections of properties. One might think of objects as octopuses with any number of tentacles, each of which has a name tattooed on it.

8.The problems that objects solve are being able to store multiple properties/data types, and combine them into a single value and group them into a a single array of log entries.

  1. One could define an Object as a collection of properties in the form of key value pairs.

  2. I would say about the mutability of Javascript objects is that they can be manipulated or modified after the original has been created making them useful because it simplifies the process of writing code.

SECOND PART

  1. Because such values are Immutable and cannot be changed.

  2. Rest parameters are represented with three dots (…) and leave open the possibility of any and all arguments that can be included.

  3. Skipped

  4. Serialisation is when we convert data into a flat description. a use case of serialisation is saving data in a file for later or sending it to another computer over the network
    more simply put, File sharing!

  5. JavaScript Object Notation. It is widely used as a data storage and communication format on the Web

  6. JSON has a few restrictions, one being that All property names have to be surrounded by double quotes, And Two,
    and only simple data expressions are allowed—no function calls, bindings, or anything that involves actual computation.

2 Likes

First Part

  1. Variable types such as strings and integers are only able to hold a single type of data.
  2. Array and object
  3. are expressions that access a property of some value
  4. Null and undefined
  5. With dot and with square brackets
  6. Properties that contain function are called methods
  7. Objects are data structures that are capable of containing an arbitrary collection of properties.
  8. Objects are special as they are able to hold as many different datatypes as we need
  9. Objects are defined as any other variable, with the value being a list contained within braces.
  10. The mutability of Javascript objects means that the values they contained can be changed.
    Second Part
  11. They have built-in properties and thet have a number of methods
  12. Rest parameter is bound to an array containing all further arguments
  13. Ok
  14. Is the process whereby an object or data structure is translated into a format suitable for transfer over a network or storage // “convert into a flat description”
  15. Json is a popular serialization format. “It is widely used as a data storage and communication format on the Web”
  16. 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.
2 Likes

Part 1

  1. We need variables which can store multiple data. Strings and integers are single values.
  2. Arrays and maybe objects.
  3. certain characteristics of values
  4. null and undefined
  5. value.x and value[x]
  6. Properties containing functions are methods. The functions do something with the value they belong to.
  7. arbitrary collections of properties.
  8. It is possible to store collections of values of multiple types into an object.
  9. var object = {...}
  10. Javascript objects are mutable, meaning that their values can be modified.

Part 2

  1. because strings are immutable
  2. in a function you might want to have an indefinite number of arguments. The rest parameter is an array containing all the remaining parameters to be included in the function.
  3. JSON stands for JavaScript Object Notation. It is the format used to save objects and arrays for use on other webpages.
  4. They are quite similar, but with a few restriction. One is allowed only to use "..." and not '...' and no function calls are allowed.
2 Likes
  1. Strings & integers cannot hold more than one value type. So the guy in the story needs something where data can be manipulated and hold more than just one value.
  2. JavaScript has a function called Arrays that can solve the problem the guy has in this story.
  3. The properties in JavaScript define characteristic about the values within the data structure. Such as the index and value .
  4. Null & undefined do not have properties.
  5. Properties can be accessed by using the dot (.) and the actual name of the property. Also using brackets within the expression. one more way to access an array is by its number sequence within the array.
  6. Methods are properties that hold function values. they are special kinds of functions that only work on the value they belong to.
  7. Objects are collections of properties, inside an object user can store various value types.
  8. Objects can store values of different type such as booleans, strings, arrays and integers.
  9. braces are used to create an object Properties inside the braces are seperated by a comma, each property name. follow by a colon and value.
  10. Objects are very different from strings, booleans and numbers. Objects can be re defined and have a different value. later on in the code without changing its original status. Once booleans, numbers and strings are written. They cannot change.

Second part

  1. because strings are immutable
    2.rest parameters are bound to an array, which contains all further arguments. this allows functions to allow any number of arguments.
  2. JSON is a popular serialization format, it stands for JavaScript Objection notation it is seen as data storage and communication format on the web and even other languages.
  3. Json JavaScript objection notation and is a popular serialisation format for data storage and communication on the web.
  4. Json requires all property names to be surrounded by double quotes and only simle data expressions are allowed meaning no comments, functions, calls, binds or anything that involves actual computation.
2 Likes

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

Its not possible to build more complex structures whith strings or integers.
In such a case u use Objects and Arrays.

2.) What variable type can be used in order to solve the problem of storing multiple values?
Arrays are list-like objects whose prototype has methods to perform traversal and mutation operations

var fruits = ['Apple', 'Banana'];
console.log(fruits.length);

3.) What are properties in Javascript?
A property is the association between an object key and its value.

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.

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

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

object.property
object['property']

6.) What are methods?
A method is a block of code which only runs when it is called.
You can pass data, known as parameters, into a method.
Methods are used to perform certain actions, and they are also known as functions.
Why use methods? To reuse code: define the code once, and use it many times.

7.) What are objects?
Objects are data structures that allow us to group values(properties,methods) —including other objects—to build more complex data structures.

In real life, a car is an object.
A car has properties like weight and color, and methods like start and stop:

Properties
car.name = Fiat
car.model = 500
car.weight = 850kg
car.color = white

Methods
car.start()
car.drive()
car.brake()
car.stop()

All cars have the same properties, but the property values differ from car to car.
All cars have the same methods, but the methods are performed at different times.

8.) What problem do objects solve that cannot be solved with other value types we’ve learned so far (such as integer, string, array, boolean etc)?
Objects can store mutliple data types (properties,methods) and even other objects into a single data structure.
This is essential to write complex programs.

9.) How do you define an object?

var car = {type:"Fiat", model:"500", color:"white"};

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

What’s immutability ?
An immutable object is an object whose state cannot be modified after it is created ,or simply (unchangeable object).

  • Immutable values cannot be modified after creation.
  • Rather than modifying them, create a new version.
  • Copying original and modify copy.

It is recommended to use immutable data structures.
Because sometimes code changes things you don’t want to be changed.

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

Values of type string, number, and Boolean are not objects und you cant set new properties on them.
This values are immutable and cannot be changed.

12.) What are rest parameters?
(Feel free to skip the sub-chapter of Math object and Destructing)

It can be useful for a function to accept any number of arguments.
To write such a function, you put three dots before the function’s last parameter

13.) What is serialisation and what is a use case of serialisation of data?
Serialization is a mechanism in which objects are converted into a sequence of bytes and, conversely, objects are created from them again.
Such mechanisms are needed, for example, for calling up via a network or for storing objects in a database

14.) What is JSON?

JavaScript Object Notation
Json is a compact data format in an easily readable text form and serves the purpose of data exchange between applications. JSON is independent of the programming language.

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

JSON only allow simple values expression like strings, numbers, arrays and booleans.
No function calls, bindings, or anything that involves actual computation

2 Likes

First Part:

  1. By introducing Arrays, it can hold multiple values.

  2. Arrays can be used in order to solve problems that contain multiple values.

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

  4. The only values that do not have properties are null and undefined.

  5. We can access properties by using a dot(value.x) or brackets(value[x]).

  6. Methods are properties that contain functions.

  7. An object are data structures that contain collections of properties.

  8. Objects can hold different datatypes.

  9. You can define an object by using braces as an expression.

  10. The mutability of Javascript objects values that it contains can be changed unlike the others.

Second Part:

  1. You cant add new properties to a string variable because a string is not can object but a primitive type.

  2. A rest parameter is the use of any number of arguments in a function.

  3. Skip.

  4. Serialization is the fact of storing your data structures to a transfer compatible format.

  5. JSON is a data storage and communicative format in the web.

  6. In JSON only simple expressions are allowed so no functions, bindings, comments, or computations.

1 Like

1.required a variable that can store multi values.
2.array.
3.properties are values,
4.javascript object notation
5.can be access properties by string after you type “.”.
6.methods are properties which contain functions.
7.object are collection of properties.
8.object can be hold in different data.
9.object is by using a braces as an expression.
10.object is mutable.

Part 2:

1.object are immutable.
2.rest parameters is an indefinite number of arguments.
3.skip
4.converting data structure or an object state in a format.
5.javascript object notation.
6.can not serialization function and complex expression that requires calculation.

1 Like
  1. With strings you have to somehow extract the digits from the data and convert them back to numbers to access them… Same goes with boolean statements… Strings and Booleans are all immutable they cannot be changed.

  2. An Array

  3. Properties - Are ways to access the value or data held inside a binding. Properties are ALSO a String.

We can use . or [ ] to access the name of the property you are trying to access. For example if i want to access the property of Value of Cars i would write. … value[“cars”]

  1. Null and Undefined
    But to add there is another bit i read about accessing numbers from a list…
    You cant use the . notation with numbers so you have to use the [ ] notation to get at them on an array.

  2. see answer 3.

  3. As far as ive read. There are two methods that have learned. One is the PUSH method where you can add a value at the end of an array. the other is a POP method that you can take away from the array. Sort of LAST IN FIRST OUT process.

let sequence = [1, 2, 3];
sequence.push(4);
sequence.push(5);

and reverse that by adding .pop());

  1. They are arbitrary collections of properties. We can create them by using braces as an expression. We add them and it creates a list of properties separated by commas. Properties whose names aren’t valid binding names or valid numbers have to be quoted. Arrays are a kind of object specialised for storing sequences of data.

  2. They contain many other values as needed. They can return undefined on one value but the other value that was stored can still be recalled as true. Because it wasn’t deleted.

  3. Object.keys function You can give it an object and it returns an array of strings and the objects property names.

  4. Values like numbers, strings, boolean etc are all immutable it is impossible to change. But, with objects they work differently. You can change their properties. if you can two of the same number they are still living two separate lives. you can change the name within it but the value remains the same.

Hey all i will post the second part later. t may be sketchy in some parts so i’m open for corrections and a discussion on what is right or wrong and where i need to improve.

@Malik

1 Like
  1. In this situation we need to store data associated with each day with days being values which we can call on request. We could theoretically assign each value of each day to unique variables and connect them to day variables, but this is impractical and much more efficiently achieved through using a layered data structure.

  2. Arrays, which are a kind of Object, can be used to assign multiple values to a single variable.

  3. In JS, properties are values that are assigned to Objects.

  4. Basically all Javascript values have properties with the exceptions being “null” and “undefined”.

  5. We can access a value’s properties by using “someValue[x]” or “someValue.x”
    “value.x” calls upon the property by its name, which is a string. This notation will not work with numbers. For numbers we use “value[x]” which tells the computer to evaluate the expression “x” and use the result, converted to a string, as the property name.

  6. In JS, a method is a property that contains a function definition. In other words, it is an action that can be performed on an object. “x.push(y);” is an example of a method. It tells the computer to take this value “y” and add it as a property to the object “x”. The “.push” is the method.

  7. Objects are arbitrary collections of properties.

  8. Objects allow us to store data and to organize that data in whatever way we see fit. This way, we can deal with large data sets inside of functions without having to address each value we are interested in by way of setting variables. We can compile all that data into one object, which we can assign one variable, and work with that variable alone.
    Take a complex analysis like correlation in the weresquirrel for example. To find out the relative occurrence of eating pizza with squirrel occurrence would require an immense amount of referencing to the 4 combination scenarios and the days on which these combinations occurred.
    Thankfully, we have Objects which allow us to assign various occurrences as properties to each day and then query each day for occurrences with if() statements.

  9. An object can be defined using curly brackets like so: someObject={property1, property2, …};

  10. JS objects are mutable. This means that, as opposed to numbers, strings and booleans, an objects’ values be changed.


  1. Strings, like numbers, are immutable, unlike objects.

  2. The rest parameter is a tool we can use to supply any number of arguments to a function, in the form of an array. It is denoted by “…” .

  3. Serialization of data allows us to take code and translate it into a computer-friendly format. This allows us to store and send it more easily.

  4. JSON stands for Javascript Object Notation. It is a syntax for storing and exchanging data. We can convert our JS code into JSON in order to store it or send it using the internet.

  5. Only simple expressions are allowed in JSON (no functions, calls, bindings) and all property names must be surrounded by double quotes.

1 Like

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

That large sets of data cause problems.

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

Array

What are properties in Javascript?

Values

Which values do not have properties?

null and undefined.

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.

What are methods?

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

What are objects?

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

When an object is written
over multiple lines, indenting it like in the example helps with readability.

How do you define an object?

To find out what properties an object has, you can use the Object.keys function. You give it an object, and it returns an array of strings—the object’s property names.

What can you say about the mutability of Javascript objects?

That the object values can be modified

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

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

What are rest parameters?

They accept any number of arguments

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

Serialization converts data into a flat description of itself.

What is JSON?

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.

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
  1. Such values are immutable and cant be changed.

  2. Resp parameters are used by calling … then the name of the function. it is then bound to an array containing all further arguments. Any before it are not part of that array.

  3. SKIP

  4. Serialisation is data that is converted into a flat description. JSON is the popular serialisation format. it is used as a data storage and communication format on the web. It takes a java script value and returns the JSON-encoded string. The Second take the string and coverts it to the value it encodes. A use case is when you have to transfer a specific piece of code between computers that hold a certain about of strings and arrays. We can address this with an encoded bag of data and transfer that instead of sending the whole computer library and tag the address.

  5. Json can encode data.

  6. All property names have to be surrounded by double quotes, and only simple data expressions are allowed. No function calls, bindings, or anything that involved computation. Comments also are not allowed.

1 Like

Hi @Rob_McCourt, Excellent answer indeed.

However, I could like to point out one small confusion.

This is not true. Properties are basically like a key-value pair. The name of the property acts as a key and the value of the property can be of any data type. The “key” cannot be considered as a string type. You can decorate the key with double quotes but even then it’s not technically a sting. For Example –

var human = { 
  name: "malik", //string value 
  "age" : 105, //number value- Even though i decorated age in quotes , it is still interpreted as a key by javascript
  hobbies: null, //null value
 }

Happy Learning! :slight_smile:

Hi @Malikthanks again. So Human is the Property in this example?

Thanks