 An object in JavaScript can have a single link to some other object. The effect of this link is that when we access a property of an object, if the object doesn't have a property of that name, JavaScript will look for a property of that name in the object linked by the first object. So say we have three objects, an object orange with three properties, a, b, and c, a red object with two properties, a, and d, and a green object with two properties, b, and e. If the green object links to the red object and the red object links to the orange object, then via the red object we can access b and c of the orange object, and via the green object we can access c of the orange object and a and d of the red object. The way to think of this behavior is that accessing a property triggers a search for that name, a search that follows the chain of links until a property of that name is found. So notice that accessing the property a via the green object returns a of the red object, not the orange, because the search starting from green goes through the red object first. So let's see how this link behavior plays out in code. For now we'll align over how to create these links, just assume that object ack here links to the object bar, and the object bar links to the object foo. Well then the expression foo.c equals bar.c equals ack.c will return true, because they actually all refer to the same property, the property c of the object foo. Bar and ack have no property c of their own, so accessing a property c on those objects foo.c follows the chain up to the foo object where a property of that name is found. Now if we then assign to bar.c a value eight, this creates a property c in the object bar. In fact, assignment to a property always affects that object itself, the link search behavior only applies when the access properties, not when we assign to them. Now that bar has its own property c, the expression act.c will return the value of that new property and bar, but foo.c will still return the value of its own property c. It turns out that the basic types in JavaScript like strings, numbers, and arrays can act in some ways like objects. A string for instance has a property named length, whose value is the number of characters in that string. For instance, this string hello has a property length with a value five, because the string has five characters. Be clear though that strings aren't really objects, you cannot assign to a string's property length or assign the string additional properties. Strings do, however, all have a link to another object, a special object which contains methods useful for strings. One such method is charat, which returns the character of the string at a specified index. When I invoke foo.char at one, the method returns a string of one character, the character it index one of the string hello, which is the second character e. Again, the indexes here start from zero, such that zero is the first character in the string. In the last line, when I invoke charat on the string of vast with an argument three, the method returns the character s, the fourth character of the string of vast. Understand what's going on in these calls, though the strings themselves have no property charat, the strings linked to an object which does, and because we invoke charat as a property via the strings, the strings get passed to the special parameter this in charat. Also understand that what this arrangement accomplishes is really nothing we couldn't do without methods, properties or object links. We could instead just have a regular function charat in the global namespace to which we would pass both a string and an index. This arrangement, however, is a bit more convenient and neatly keeps the global namespace uncloded. To create a link from one object to another involves the new operator. The new operator is a unary operator which takes as its operand a call to a function. What the new operator does is pass a newly created object to that function's special parameter this and what the function then returns, regardless of any return statement, is that newly created object. So here when we invoke this function Tom with the new operator, a newly created object is passed to the special parameter this. The object then gets assigned to properties foo and bar and the newly created object is returned and assigned to the variable Jane. Now it turns out that every function value has a property called prototype, an object which starts out empty when the function is created. When we invoke a function with the new operator, the newly created object gets linked to this prototype object. So here if we create a property ac in the prototype object of Tom, we can then access ac via the Jane object because the Jane object links to the prototype object of Tom. Again, the JavaScript equivalent of what pigeon calls a list, JavaScript calls an array. An array is created with a literal syntax of square brackets enclosing a list of values separated by commas. To access modify or add items, we use square brackets much like we do to access modify or add properties of objects, except inside the brackets, we put a numeric index rather than a string. So here, for example, we assign the foo an empty array, and then assign the bar an array of three items, the number four, a string hello, and the number 33. We then assign the ac the item of bar at index two, in other words, the third item of bar, the value 33. Lastly, we assign the index three of bar a string orange. Because bar previously had no item at index three, this effectively expands the size of the array by one. Unlike pigeon, we don't have to explicitly expand an array within a append operation. We can instead simply assign to any index, whether the index is currently in range of the array's current size or not. In fact, the dirty secret of JavaScript's arrays is that they are really just objects in disguise. The item of an array at say index two is really just a property with a name numeral two. So if you write these numeric indexes as strings, the code actually functions just the same. The only way arrays really differ from objects is that arrays have a special property called length, which is meant to report the number of items in the array. In truth, though, what the length property actually reports is the number which is one higher than the greatest numeric property name. So here, foo dot length returns zero and bar dot length returns three as we should expect. However, if we then assigned the index 15 of bar bar dot length returns 16, even though we've only added one more item, all the indexes from four to 14 such as index eight remain undefined. So understand that there are scenarios in which the length property will actually misreport the number of items in an array. Inside a function, JavaScript always includes a special local variable called arguments. The arguments variable holds an array of all the arguments passed to the function. Whereas in pigeon, a function must always be called with the same number of arguments as the function has parameters. In JavaScript, a function can always be called with any number of arguments. When the function is called with fewer arguments than the function has parameters, the excess parameters get the value undefined. When a function is called with more arguments than the function has parameters, the only way to access these access arguments in the function is via the arguments array. Using the arguments array we can write a function which sums together all the arguments passed to the function no matter how many arguments are given. We'll call this function sum and notice it has no parameters. In the function we use a variable sum to keep tally of the value we're going to return and we use a counter variable i to step through each item of the arguments array in a loop. i starts out at zero and gets incremented by one at the end of each iteration and the condition tests whether i is less than arguments dot length. So the loop will iterate with i incremented from zero up to but one less than the length of the arguments array. In each iteration we take the item of the arguments array at index i and add it to our sum. Once the loop completes we return sum. So if we call the sum function with the arguments two, two, and three we get seven. Sum with arguments five and seven returns 12 and sum with no arguments returns zero because when the arguments array is empty the loop is never entered and so the initial value of sum zero is returned.