- The ablillity to work with chuncks of data
- arrays
- Properties are the execution of a certain behaviour. Like, .lenght that counts the length of a value
- null and undefined
- with a value.x or value=[x], they are not always the same though
- properties with functions in them
- objects are octopuses with any number of tentacles, each of which has a name tattooed on it.
- it can create many bindings
- The values of the type object are arbitrary collections of properties.
- numbers, strings, and Booleans, are allimmutable. Were as objects can actually change values
- It introduces us to a problem that requires us to store multiple data under a single variable. We need a data structure in order to determine the cause of his problem.
- An array can be used in order to solve the problem of storing multiple values.
- Properties in javascript can show us special characteristic about some values.
- Null and undefined.
- They can be accessed either by a . or with an expression in the brackets [].
- Methods are like properties but they themself have functions that change the variable in a certain way and then display us back the property we asked for.
- Object are values that can contain a lot of properties
- Objects can hold as many data as we want, which enables us to solve the current problem.
- Binding to an expression enclosed by brackets.
- An array can be used in order to solve the problem of storing multiple values.
SECOND PART:
- Javascript does not allow additional properties to be added or removed from a string variable.
- Rest parameters accept any amount of arguments.
- Skipped.
- Serialization enables us to convert data structures into a format that can be stored in our computer and thus be send over to another computer.
- JSON is a standard file for data storage or communication over the internet.
- In JSON, only simple data expressions are allowed. For instance, expressions that involve computation or comments are not accepted. All property names need to be surrounded with double quotes. With JSON, data are simplified to be easier to read and use.
- He needs variable that can store mulitple values.
- Arrays can store multiple values.
- Properties are expressions that access a property of almost all JavaScript value.
4.null and undefined.
5.The two main ways to access a value’s property are with a dot and a square bracket. - A method is a property that holds function for a type of value. For example the
.push method adds values to the end of an array.
7.Objects are values of arbitrary collections of properties. - Object tie different properties together to express a single condition.
9.Braces are used to create objects. Properties inside the braces are separated by commas. Each property is named, follow by a colon and a value.
10.Unlike numbers, strings and Booleans, which are immutable values, objects can be modified. Objects can have their properties changed.
Part 2:
1.Because string variables are immutable
2.These are denoted by a function’s last parameter with 3 dots before its name and are useful for functions that accept any number of arguments. When the function is called, the rest parameter is bound to an array containing all further arguments.
3.-
4. Serialisation is converting data stored in memory into a flat description of what that data is. It is useful for when we want to do things like saving the data to a file or transferring it to another computer on a network.
5. JSON is a popular serialization format, it stands for JavaScript Object Notation, it is used as a data storage and communication format on the Web and even for other languages
6. 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.
- Strings & integers can hold only a single type of data. We need to store multiple values
- Arrays
- Every value has its own property
- Null and undefined
- Two ways
- a dot. => “array.length”
- exact name => “array[“length”]”
- They are also properties that hold function values.
- “toUpperCase”
- Set of data defined by curly braces
var object = {Name: “Martin”, Grade:10}; - They can hold various data types
- curly braces, see above (7.)
- Values can be changed, and enables developers to do more => flexibility
- String is immutable
- Can accept any number of arguments
- “…” (three dots used)
- Used i.e. when you want to transfer date from one computer to another or another computer
- data are translated into such format suitable for transfer
- JavaScript Object Notation is a serialisation format (used very often)
- Only simple data can be used and property names have to be inside double quotes
- A variable type is needed that can store multiple values.
- An array.
- Properties are values inside an object.
- Null and undefined.
- With a dot . and square brackets [].
- Functions in an object.
- Objects are a collection of properites.
- Objects can hold values in diffrent datatypes.
- Objects are defined using curly braces { }.
- A mutable object is an object whose state can be modified after it is created.
Second Part - Primitive data types such as strings, integers and booleans they are immutable and can’t be changed.
- Rest parameter is an improved way to handle function parameter, allowing us to handle various input as parameters in a function.
- Serialization is a mechanism for storing an object’s states into a persistent storage like disk files, databases, or sending object’s states over the network.
- JSON is a lightweight format for storing and transporting data.
- All property names must be surrounded by double quotes and only simple expressions are allowed.
Part One
Read the sub-chapter called The weresquirrel. What problems does this chapter introduce that cannot be solved with variable types such as strings or integers?
Storing values in a row cannot be solved by data types as strings or integers
What variable type can be used in order to solve the problem of storing multiple values?
Arrays like this
let myArray = [6, 2,´1, 5, 9];
What are properties in Javascript?
Properties are values inside an object.
Which values do not have properties?
null and undefined
How can we access properties in a value (two ways)?
You can access properties using . notation such as st.length, or square brackets such as st[x]
What are methods?
Methods are functions within and object
What are objects?
Values of 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)?
We can bundle arbitrary collections of properties in a structured way.
How do you define an object?
You define an object 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.
What can you say about the mutability of Javascript objects?
Unlike the data type of strings, objects enable for objects to be changed
Part Two
Why can’t you add new properties to a string variable?
Javascript does not allow additional properties to be added or removed from a string variable because string is immutable
What are rest parameters?
Parameters that accept any number of arguments
What is serialisation and what is a use case of serialisation of data?
Serialisation is the conversion of data into a flat description, which allows the data to be saved in a file or send to another computer.
What is JSON?
JSON is JavaScript Object Notation, it is a format of serialization for data storage and transmission on the Web, and it even used by other languages.
What are the differences between JSON and the way programmers write objects in plain Javascript?
The main difference between JSON and plain Javascript written objects is that JSON’s data files only allow simplified direct expressions with no computations, functions or bindings. Also, all property names need to be surrounded by speech marks.
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 a huge number of datapoints that needs to be sorted and also needs to be accessible. Easy accessibility allows the you to easily analyze the datasets to find the cause. This is not possible with strings or integers because it requires defining a lot of variables and analyzing is much more difficult. Since you need to remember and plan how you stored the datapoints.
What variable type can be used in order to solve the problem of storing multiple values?
It is called an array variable. An array stores is good in storing multiple things in sequence, where the entries are numbered from 0, 1, 2, …… N-1. An array is defined by using square brackets.
What are properties in Javascript?
Properties of a variable gives us extra information about the stored value. Properties are usually not defined by the user but calculated by using the stored value. For example a string variable myString is defined as “Hello”. A property of the string variable is myString.length gives you the length of the string.
Which values do not have properties?
null and undefined
How can we access properties in a value (two ways)?
By using a dot or a square brackets. For example we want to access the property x of variable myVariable . The methods are myVariable.x or myVariable[x] . By using a dot you are accessing the property x. By using a bracket, the expressions within the bracket will be evaluated and the result is the property value that will accessed.
What are methods?
Property that contains a functions is called a method. Method uses the value of its variable to deliver the result without passing the arguments into the function.
What are objects?
An object variable stores multiple values/datasets as properties of the variable. To store a value or dataset one needs to define the property name and the value that needs to be stored.
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)?
It introduces the possibility to group different variables into a single object variable, while maintaining its unique name. The name is converted from variable name to property name.
How do you define an object?
An object is defined by using curly brackets. For example:
Let myObject = {PropertyA: 5, PropertyB: 6}
What can you say about the mutability of Javascript objects?
The values of a JavaScript object are not immutable and can be changed from time to time. Other variables types, such as numbers, strings and Booleans, are immutable and cannot be changed.
Part 2
Why can’t you add new properties to a string variable?
A string variable is immutable and therefore you cannot add new properties to a string variable.
What are rest parameters?
Rest parameter is defined by three dots such as …numbers . A rest parameter accepts any number of arguments and stores it an array.
What is serialisation and what is a use case of serialisation of data?
Serializing the data means converting information into a flat description. The use case is storing data and sending it to other computers.
What is JSON?
JSON is a serialization format and stands for JavaScript Object Notation. JSON is a popular format for storing and transmitting data across the web.
What are the differences between JSON and the way programmers write objects in plain Javascript?
The difference between JSON and JavaScipt way of programming is that:
- All property is defined between double quotes.
- Only simple expressions are allowed so no binding, methods, function calles, comments etc.
1st part:
- Read the sub-chapter called The weresquirrel. What problems does this chapter introduce that cannot be solved with variable types such as strings or integers?
strings or intergers cannot store large collection of data - What variable type can be used in order to solve the problem of storing multiple values? arrays
- What are properties in Javascript? is a key value pair related to a data type or object
- Which values do not have properties? null and underfined
- How can we access properties in a value (two ways)? dot and square brackets
- What are methods? are properties which hold function values.
- What are objects? is a collection of properties holding data and ma or may not contain methods of that object
- 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)? can create Object as we want and can defined the behaviour as needed to modify their state.
9.How do you define an object? binging and its value in braces - What can you say about the mutability of Javascript objects?values can be altered
SECOND PART:
- Why can’t you add new properties to a string variable? strings are immutable
- What are rest parameters? represent an array with all agruements that will be included and called by writing three dots before the functions name
- (Feel free to skip the sub-chapter of Math object and Destructing)
- What is serialisation and what is a use case of serialisation of data? the fact to convert data stored in memory into a flat description
- What is JSON? serialization format widely used for data storage and communication
- What are the differences between JSON and the way programmers write objects in plain Javascript? simple expressions are allowed in JSON, no function calls, bindings, or anything involves actual computation
- Variables are not suitable for this problem due to the fact that it’s difficult to store and extract multiple values from them. Also, the variables such as String and Integer, are immutable, which makes it impossible to modify their properties if needed.
- The Array can be used in this case.
- Properties can be described as attributes of almost all JavaScript values. Those can be the length of the string or size of the array.
- Null and undefined
- We can use dot notation, for example, by placing .length after the value. Or we can use bracket notation such as object[name].
- Methods are the properties that contain a function like toUpperCase() one.
- Objects are arbitrary collections of properties.
- Objects can store multiple properties and their values, therefore they can be used to build complex data structures.
- We can define the object by declaring a variable and assigning it to values between braces. For example:
let object = {
name: “Tomcio”
} - One can change the properties of the object, causing a single object value to have different content at different times.
SECOND PART
- Because the string is immutable and its values cannot be changed.
- The rest parameters represent an indefinite number of arguments as an array. One can use such a parameter by putting three dots before the argument of the function.
- No problem.
- Serialization is a method to convert the data into a flat description. The use case is then one can save data and send it over the network of computers efficiently.
- JSON is widely used as a data storage and communication format on the Web, even in languages other than JavaScript.
- There are a few differences. 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. Also, comments are not allowed in JSON.
PART ONE:
-
It introduces the problem of causality, to know which conditions trigger certain events.
-
This variable is called “array”.
-
Properties are attributes of values. For example, “length” is a property of value “string” and expressed as “string.length”
-
Values “null” and “undefined” don’t have properties.
-
Properties in a value can be accessed by a dot or with square brackets (value.x or value[x]). When using a dot, the word after it is the literal name of the property. When using square brackets the name between the brackets is evaluated to get the property name.
-
Methods are functions that live in properties and act usually on the value they are property of.
-
Objects are collections of properties that provide a possibility to put multiple values into one single value.
-
Objects make programming more convenient and faster since you can wrap pieces of code together instead of storing them separately.
-
You define an object by using curly brackets. Inside them you write a list of properties separated by commas. Each property has a name followed by a colon and a value. For example:
let object = {property1: 1, property2: 2}
-
JavaScript object values are mutable, whereas strings, arrays, integers and Booleans are all immutable. You can change the properties of objects, but it doesn’t necessarily affect the identity of the object. The example given in the book:
let object1 = {value: 10};
let object2 = object1;
let object3 = {value: 10};
console.log(object1 == object2); // → true
console.log(object1 == object3); // → falseThere is no “deep” comparison built into JavaScript that can compare objects
by their contents, but it’s possible to write yourself.
PART TWO
-
String variables are not objects and they can’t store properties. They are immutable so they can’t be changed.
-
Rest parameters allow us to represent an infinite number of arguments as an array.
-
Serialization is converting data into a flat description, so it’s more convenient to communicate on the web.
-
JSON (JavaScript Object Notation) is a popular data serialization format.
-
In JSON all property names have to be surrounded by double quotes, and only simple data expressions are allowed (no bindings, function calls or anything that includes computation). Also comments are not allowed in JSON.
Part One
-
The problem that can’t be solved is that we need to be able to store multiple values in a variable, and we can’t do that with strings and integers.
-
The variable type that solves the problem of storing multiple values is the Array.
-
Properties are values associated with objects in JavaScript.
-
The values that don’t have properties are null and undefined.
-
We can access properties in a value by using a dot and with square brackets.
-
Methods are properties that contain a function.
-
Objects are arbitrary collections of properties.
-
Objects allow us to group a set of values to a specific value. That way you can add the group of values to arrays using the one value where the values (objects) are stored.
-
An object can be defined by using braces as an expression.
-
Objects have mutability because it is possible to change their properties causing a single object to have different content at different times.
Second Part
-
You can’t add new properties to string values because they are not objects.
-
Rest parameters are the representation of any amount of arguments as an array. It is called by using three dots before the argument of a function.
-
Skipping them
-
Serialization is the conversion of data into a flat description, and it can be used to send all memory addresses (data) through the network or be saved in a file for later.
-
JSON (JavaScript Object Notation) is a serialization format used for data storage and communication in the Web.
-
The differences between JSON and plain JavaScript are: All property names have to be surrounded by double quotes, only simple data expressions are allowed (nothing that requires computation), and comments aren’t allowed either.
Glenn_CostaRica
PART I: DATA STRUCTURES: OBJECTS AND ARRAYS
‘’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’
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?
With an integer or a string, we can store one type of data in one place (in one particular address in memory). Each one, the integer or the string, constitute – as other kinds of atomic types of data represented by variables – can store one single piece of information of the one single stype. In the chapter, a new level of problems is presented: the need to handle more than one piece of data, even large amounts of data pieces, in one single place, as well as the need of having in this very same place a plural number of types of data.
2. What variable type can be used in order to solve the problem of storing multiple values?
We can solve the problem by using Objects. One more type we can use is Arrays which, in essence, are a very particular type of objects.
3. What are properties in Javascript?
Properties are characteristics asociated to Objects, or values that are assigned to Objects. An Object is made of a set of properties.
4. Which values do not have properties?
Values refer to properties, or are particular states of a property, except for “Null” and “Undefined” which are not values of a particular property.
5, How can we access properties in a value (two ways)?
There are two ways: i. dot and ii. square brackets: data.3 or data[5-2].
6. What are methods?
A method can be thought of as a property given by a function or associated to a function. As any function, methods can return a value and can modify the data of properties.
7. What are objects?
An object is a set of properties organized as one unit of identity. An example of an object would be the instantiation of this case.
var objectPerson = {
var name;
var age;
var profession;
};
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 give us the capacity to group sets of different properties and treat them as one single property, just a we treat an integer, a string or a boolean property.
9. How do you define an object?
Objects are defined in a very similar way as other variables. The values for the properties can be given as a list contained within braces, a list of properties separated by commas.
10. What can you say about the mutability of Javascript objects?
Objects are mutable in JavaScript. The types of values they contain can change during execution. This is impossible for a boolean value, or for numbers or strings, since these are primitives and primitives are immutable: once you declare and initialize a primitive, it will stay as the same type of value.
PART II: STRINGS AND THEIR PROPERTIES
‘’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’’
1. Why can’t you add new properties to a string variable?
Strings are primitive types: as such, they are immutable. We cannot add properties or functionality to them. "Values of type string, number, and Boolean are not objects, and though the language doesn’t complain if you try to set new properties on them, it doesn’t actually store those properties. As mentioned earlier, such values are immutable and cannot be changed. But these types do have built-in properties. Every string value has a number of methods. Some very useful ones are --> slice and --> indexOf , which resemble the array methods of the same name.
console.log(“coconuts”.slice(4, 7));
// → nut
console.log(“coconut”.indexOf(“u”));
// → 5
2. What are rest parameters?
A rest parameter is an argument for a function that happpens to be an array.
3. What is serialisation and what is a use case of serialisation of data?
A JavaScript program typically includes many types of nested data structures. Within a main object there can be hundreds of properties and objects, and within internal objects there can be real trees of objects of objects. In case, for example, that a program needs to be communicated over a network, all this superstructure cannot be sent as such. So the all objects within the structure must be serialized. Thus, the entire superstructure becomes a linear sequence, as a kind of data string, in a standard format. Some standard serialized data formats are JSON, XML, and Yaml.
4. What is JSON?
JSON stands for JavaScript Object Notation. It is a popular format for serialised data.
5. What are the differences between JSON and the way programmers write objects in plain Javascript?
In JSON, some restrictions must be respected, like property names which must be surrounded by double quotes. Also only simple data expressions are allowed — no function calls, bindings, or invocation that implies execution of computation. Also, Comments are not allowed.
1Read the sub-chapter called The weresquirrel. What
problems does this chapter introduce that cannot be solved with variable types such as strings or integers?
There are situations where you need to group values, like a list of integers, together into a single data structure. Strings and integers are not good at this.
2What variable type can be used in order to solve the problem of storing multiple values?
An Array.
3What are properties in Javascript?
Informational attributes of an object which are stored in an array
4Which values do not have properties?
null and undefined
5How can we access properties in a value (two ways)?
with “.” notation or [] notation
6What are methods?
An object property that holds a function values, ie perfroms a function on the value.
7What are objects?
Objects are arbitrary collections of properties
8What problem do objects solve that cannot be solved with other value types we’ve learned so far (such as integer, string, array, boolean etc)?
9How do you define an object?
define a value and list its properties, as property:value, within {}
10What can you say about the mutability of Javascript objects?
Their properties are easily mutable. A single object value can have different values at different times. But objects with the same property:value pairs are not the same.
11Why can’t you add new properties to a string variable?
Because strings are not objects. They are immutable.
12What are rest parameters?
A parameter that is bound to an array function arguments regardless of the array length
13What is serialisation and what is a use case of serialisation of data?
14What is JSON?
A popular serialization format for data storage and communication
15What are the differences between JSON and the way programmers write objects in plain Javascript?
Property names have to be surrounded by double quotes and only simple data expressions are allowed–ie no functions. Also, no comments.
First Part
- The problem is that strings and integers can only hold a specific type of data, while in this case there were several information of different nature to be recorded.
- The best variable type, for what we’ve studied so far, should be arrays, since they allow to store different types of data.
- Properties are features that values have that distinguish them from different values and can be accessed to retrieve information about each value.
- Null and undefined are the only exceptions, because they have no properties.
- By using a dot before the literal name of the property or putting an expression within square brackets to receive the property name.
- Methods are properties containing functions.
- Objects are collections of properties in which multiple values of different kinds are stored.
- They allow to store different types of values within the same object.
- By using brackets, separating properties with commas and properly writing properties.
- Unlike numbers, strings and booleans, objects are mutable because it is possible to change their properties.
Second Part
- Because each specific string value has a property which cannot be changed without changing the string itself. If I were to modify the string “cat” to “rat” I would simply have a different string, not a changed string value.
- Rest parameters allow to set an indefinite number of arguments as an array.
- Serialisation is a method to convert data in a flat description to make it less complex and memory-intensive to transfer data.
- JSon is a serialisation format used to store data and for format communication on the Web.
- Property names have to be double quoted, only simple data expressions are allowed (so, nothing that would require computations like functions) and comments are not allowed.
1.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?
Handling large set of data that have similar properties, thus the need for objects and arrays.
1.2. What variable type can be used in order to solve the problem of storing multiple values?
objects and arrays (which are a specific type of object)
1.3. What are properties in Javascript?
variables or functions related to an object
1.4. Which values do not have properties?
null and undefined
1.5. How can we access properties in a value (two ways)?
by using the name or the location :
value.property
value.[“property location”]
1.6. What are methods?
Functions, i.e. a property that is a function.
1.7. What are objects?
A grouping of values into a single one.
1.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)?
Their value can be modified.
1.9. How do you define an object?
var objectName = {
property1: value1,
property2: [arrayValue1, arrayValue2, arrayValue3]
};
1.10. What can you say about the mutability of Javascript objects?
The value of an object can be modified.
2.1. Why can’t you add new properties to a string variable?
It is a static value. You can put the string in an object and add properties to that object. The string value becomes a property of the object.
2.2. What are rest parameters?
They are parameters that give direct access to the content of an array.
2.3. (Feel free to skip the sub-chapter of Math object and Destructing)
Not applicable.
2.4. What is serialisation and what is a use case of serialisation of data?
Put data in a sequence used to send data.
2.5. What is JSON?
JSON is a serialisation format used as a data storage and communication format on the Web.
2.6. What are the differences between JSON and the way programmers write objects in plain Javascript?
- Property names have to be surrounded by double quotes.
- Only simple data expressions are allowed (no function calls, bindings, or anything that involves actual computation.)
- Comments are not allowed.
-
With a normal variable such as strings/ integers you can only store just one single value of a specific type (string, integers). And with a normal variable you cannot combine two different variable types. In real world applications you need to store a lot of data in just one variable. This is done by defining a variable and declare it as an array, where you can store multiple values of one or several types (strings, integers etc.).
-
You can store multiple values in an arrays or objects. Arrays can be used for storing multiple values of one type (strings, integers) as well as multiple values with multiple types (in this case you have an array with objects inside). Objects can store multiple values and multiple data types.
-
Every object in Javascript has properties (you can think of it as attributes which e. g. a person have: age, height, gender…). Through the properties you have access to the associated value and change, update, delete or only read them.
-
null, undefined
-
First way: With a dot (.). For example, ExampleObject.ExampleProperty.
In concrete an example: Person.Age where Person is the object and age is the associated property.
Second way: With square brackets ( [] ). In my Person example: Person[“age”] -
Properties can be values (such as strings or numbers or a combination) but also functions. These function properties are also called methods. When you call a property which is a function then you are using a method of this object. We already know that a function is doing something (with or without a return of something).
-
Objects can store multiple information and they can be from entirely different types (every valid property you can imagine). That means, you can store in Objects “everything you want”.
-
An object allows us to store more than one data/value type (e. g. numbers and boolean) in a single variable which has to be declare as an object. You can group all information together (doesn´t matter which data type) and collect them as a bunch of properties in the object.
-
You can do it by defining a variable and assign it with braces {}:
let ExampleObject = {
boolean_example_variable: true,
string_example_variable: ["Ex1", "Ex2"]
};
- Objects in Javascript are not immutable. This is in contrast do the other data types we have learned before. You cannot change a number or string. With objects this is different. You can access to a specific property and e. g. change the value inside of this object. With integers, strings etc. it would be not possible.
SECOND PART
-
A string is not an object. Therefore, a string immutable and this means you cannot add new properties to it. Only objects are mutable and their properties can be manipulated.
-
The defining of a rest parameter is generated by 3 dots before its name (e. g. function example(…argument1) )Rest parameters allows us to give an indefinite numbers of arguments as an array, for example to a function
-
Have read it.
-
Serialisation of data is needed to send files or data e. g. through a network (data has to be require a string). Therefore, you can encode your file/data in a string (this is for example done via JSON). These transformation from an object into a primitive string is called serialisation. When the file/data has arrived its target it is converted back (deserialization) from a string to an object where it can be further manipulated.
-
JSON is Javascript Object Notation. As described in 4 JSON is a format that encodes objects in a string which allows then the user to send this data to another computer. JSON is so to say a data storaga/ communication format on the Web.
-
In JSON all properties are surrounded by double quotes, only simple data expressions are allowed (that means no computation is possible). Also comments are not allowed.
In terms of the person example (person object has a property age) which I described before a JSON data would look like this
{ “age”: 12, …
}
wheres in an object it would look like this
{ age: 12, …
}
-
The chapter introduces problems that require data sets. These datasets may be of elements of the same type (e.g. numbers) or may require more complex datastes where each entry is composed of multiple elements that may be of different types (e.g. strings, numbers, booleans).
-
Arrays can be used for storing multiple values.
-
Properties (in Javascript) access some property/attribute that belongs to a value. Almost all values (in Javascipt) have properties.
-
In Javascript the only two values that don’t have properties are: null and undefined.
-
Properties can be accessed either by value. where the name after the dot is the literal name of the property (eg. as in myString.length ).
The second way properties can be access is via or value[ index ] where index (within square brackets) is an expression that evaluates to the properties name. Therefore myArray.length is equivalent to myArray[“length”] -
Methods are functions that are contained by properties.
-
An object is an arbitrary definition that specifies a collection of properties.
-
When we require complex datastructures and object can be defined to represent the required data structure.
-
Objects can be defined using curly brackets { } . For example : let personObject = { name: “Alice”, age : 23, single: true};
-
Javascript objects are mutable meaning that an objects values can be modified. Therefore an object can change its properties, so that a single object can have different values at different times. E.g. the following would be a valid operation on the object personObject previously defined above : personObject.single = false;
Second Part
-
A string variable is immutable, which means it can’t be changed and hence new properties can’t be added.
-
A rest parameter is a parameter (to a function) that is bound to an array and as such represents any number of arguments (i.e. the items that are present in the array at the time that the function is called).
-
Serialisation is when data structures such an array or object (in JavaScript) are converted into a flat format (ie. a format that doesn’t depend on storing array or object data sequentially in computer memory, with embedded objects (in the outer object) having to be stored sequentially in another block of memory - with an address reference to it from the outer object).
Serialisation is used when data needs to be sent over a network between computers, or if we want to save data into a file for later use. -
JSON is a format for serialisation of data. It is a widely employed format across many languages (not just Javascript).
-
JSON is similar to how programmers define objects in Javascript, with some additional restrictions. Specifically:
i) Property names must be enclosed in double quotes.
ii) Only simple expressions allowed (so nothing that performs computation)
iii) Comments are not allowed.