turingschool-examples / intermission-assignments

33 stars 217 forks source link

Eloquent JavaScript #94

Open Carmer opened 7 years ago

Carmer commented 7 years ago

In a comment on this issue, state what you found to be a valuable thing you read from Eloquent JavaScript.

Please use this github issue as a forum to ask and answer questions you came across in the from the reading.

jesse-spevack commented 7 years ago

Eloquent JavaScript Chapter 3: Functions

susiirwin commented 7 years ago

I think the biggest point of value is to be consistent with good practices. Each of the readings generally have the same principles on them and that really drives home the point in writing clean code. Keep things readable. Keep things to the SRP. IN EJ specifically, I was really interested in the chapter on Objects - specifically when talking about this and prototypes - since i had to use these in the exercisms. seeing that by using prototype affords us a few out of the box methods is extremely helpful.

NateAnderson1780 commented 7 years ago

Eloquent Javascript, Chapter 3 - Functions

Eloquent Javascript, Chapter 5 - Higher-Order Functions

Eloquent Javascript, Chapter 6 - Secret Life of Objects

Eloquent Javascript, Chapter 17 - Objects & Inheritance

Javascript Garden

bheim6 commented 7 years ago

Eloquent JS Ch. 3: Functions

Eloquent JS Ch. 5: Higher-Order Functions

Eloquent JS Ch. 6: The secret life of objects

Speaking JS Ch. 17: Objects and Inheritance

JavaScript Garden

danbroadbent commented 7 years ago

Chapter 3 (Eloquent): Functions

Chapter 5 (Eloquent): Higher Order Functions

Chapter 6: (Eloquent) The Secret Life of Objects

Chapter 17: Objects and Inheritance (Speaking JavaScript)

JavaScript Garden

rdavid1099 commented 7 years ago

Chapter 3 (Eloquent): Functions This chapter was extremely valuable to me. It wasn't until I understood the power and structure of functions that JavaScript actually began to click in my mind. Learning that I could save functions to variables and call those variables similarly to Ruby methods was awesome. Weird nuances with functions that I learned is the fact that functions must have () to take arguments, even if the function doesn't take any arguments. Also, the fact that functions MUST SPECIFICALLY return a value is pretty interesting. I caught myself often forgetting to "return" things while working through those exercises. The nice thing about JavaScript functions, they are a lot more easy-going than other languages, such as C#, which makes you declare the type of value the function is returning. That's great.

Chapter 5 (Eloquent): Higher Order Functions Right off the bat, this chapter really spoke to me, saying that complexity is the death of an efficient program. I think I have a tendency to write uglier and more complex programs when working with lower level languages. For some reason, the curly braces and semicolons make it naturally look ugly and make me think I have a pass on writing clean, clear code. This chapter proved why my tendencies are not correct. This chapter easily has some of the coolest things I've learned so far about JavaScript. Learning about using and creating higher-order functions and using functions as arguments for other functions is amazing. These concepts hit very close to what I learned while working through Lololodash. It was extremely confusing to see functions within the parameters at first, but after realizing the order of operations, it became clear how powerful higher-order functions can be when writing complex problems. It is important, however, to remember to keep things as simple as possible and not create complex functions for complex-sake. Complexity can make code difficult for others to work on and may hurt efficiency and run-time.

Chapter 6: (Eloquent) The Secret Life of Objects This chapter was a great read. I feel like one of the most difficult things to learn about JavaScript after learning Ruby is JS Objects. While we relate them to hashes, they are not exactly the same as the hashes we know and love. I noticed this while comparing my exercisms work with others. More advanced coders could use and manipulate JS objects to do a whole lot more than just store and recall values. This chapter showed several awesome concepts including using object keys to refer to functions. This use looks a lot like class methods... but under the hood, it's working completely different than Ruby. I still need to do a lot more research and messing around to fully grasp the concept of prototypes. Reading about it felt similar to when Jeff initially showed us the abstract depth of Ruby classes and prime classes. While in theory it makes a bit of sense, I am not fully understanding what is happening in the background. It's interesting, actually, considering that while working through Exercisms, I was manipulating the prototype and didn't even realize it. Overall, this chapter showed me just how much was happening in the background... and how important it is to understand the ins and outs of objects to write truly magnificent and efficient programs. I am definitely going to re-read this chapter.

Chapter 17: Objects and Inheritance (Speaking JavaScript) Diving deeper into the JavaScript pool... The depth and power of JS objects continues to baffle me. While I feel like I was holding on to what was happening in this chapter, it was easy to get tripped up and confused. The more I learn about dot operators and how objects can hold functions, the more I realize how you can manipulate JavaScript to do similar things as Ruby. At the same time, however, objects can be as simple as hashes, using functions such as keys, you can navigate the object in the same way a Ruby hash can be navigated. This chapter was very dense, with a lot of interesting information, but, to be honest, the whole time I was reading I just felt like I needed to apply the knowledge to fully understand it and learn it. It's definitely beneficial to at least be exposed to the concepts, and I will be saving a link to this chapter for future reference.

JavaScript Garden Another great resource for future reference. I really think this reading should have been the first thing we did for prework before jumping into the NodeSchool. It's a clear and well-written piece of all the weird nuances JavaScript has. There is little to no assumed back knowledge, and knowing what we know about Ruby and other programming languages, I thought it did a good job pointing out the major differences and how to avoid falling into the pitfalls. I honestly learned a whole lot more reading through this documentation and am excited to apply my new skills. The way JS Garden described prototypes really helped my understanding. I am learning the differences between Ruby and JS and inheritance. While Ruby directly inherits, JS uses prototypes to emulate the inheritance feeling. Learning how to chain prototypes together makes a lot of sense, and I really feel that concept starting to click. Learning more about function declarations was very helpful. I have been going back and forth with whether I should declare a function similar to Ruby or declare a variable which equals a function. I am still struggling to understand the full scope of 'this' and how it is different than 'self' in Ruby. I think the idea of the global scope is throwing me off. Arrays in JavaScript are real interesting. I don't know what it is, but I'm really kind of liking the lack of enumerables and the custom ways you can work your way through arrays. Overall, this was a great read, and I can't wait to refer back to it as I'm writing some awesome JavaScript programs.

JeanJoeris commented 7 years ago

chap 3 - functions I appreciated the clarification on how js handles scoping, especially that each function creates its own scope. I like the let {} block, as the ability to define mine own scope when needed is useful. I also didn't realize the difference between var foo = function()... and function foo() = .... I'm not sure how the function syntax moves the function to the top when javascript is interpreted. As I've been learning Elixir and functional programming over the break, it is nice that javascript has closures and first class functions. The very loose attitude about arrity of functions is frustrating however. I'm also reluctant to use closures in a language where the variables passed into the closure can be changed outside the closure (boo mutability!)

chap 5 - higher order functions I think it is very useful to see that patterns we are used to as enumerables in Ruby are relatively straight-forward to build. They are similar to an explicit for-loop, but designed with a general purpose (i.e. map applies a function to an array). I feel like I got more out of this because I had recently built these functions (map, reduce, etc.) with recursion in a functional programming language. As many problems as I have with javascript, the ability to easily pass functions (named and anonymous) as arguments is very useful

chap 6 - the secret life of objects The most useful thing about this article was learning about prototypes and the javascript inheritance model. Prototypes seem very similar to inheritance, the Object object in Ruby (and the idea of eigenclasses), but they are used in ways similar to a class definition. Constructors seem to be how javascript handles the idea of class, particular given the instanceOf syntax. The ideas of polymorphism and encapsulation seem the same as Ruby.

chap 17 - objects and inheritance There is a lot going on in this reading. While a lot of the material has been covered in the previous chapters, this describes the same ideas in a much denser way. It was nice to get explicit confirmation of my understanding of constructors as analogous to classes. The biggest take away for me wasn't a particular thing I learned but that (essentially) everything I already know has equivalents in javascript, even if they are much uglier. Also, spending time with a pure functional language over break (Elixir) I find it quite frustrating that even Object.freeze(obj) leaves values somewhat mutable.

javascript garden - This is awesome! A website that explicit acknowledges the weirdness of javascript and gives a frank discussion of workarounds and common frustrations. I really appreciated the clarification that prototype is a different model of inheritance. Prototyping felt similar to inheritance but I wasn't sure what was different about it. It was also super helpful that they explicitly layout 5 different cases for the meaning of this, which helped clear up my confusion regarding this. I also really appreciated the discussion of automatically inserting semicolons. I had heard 'javascript doesn't require semicolons' said somewhat jokingly, and now I understand

rsbarbo commented 7 years ago

Chapter # 3 - Functions

Chapter # 5 - Higher-Order Functions

Chapter # 6 - The Secret Life of Objects

Chapter # 17 - objects and inheritance It seemed to me that this chapter was added to our read in order to further our knowledge in functions, objects, constructors, and so on. The biggest take away here is that I can pretty much apply all the knowledge learned in Ruby in JavaScript, the key is understanding how similar approaches are applied differently in JS.

JavaScript Garden

It is necessary to understand the prototypal inheritance model before being able to write complex code that makes use of it. Also, it is very important to be aware of the length of the prototype chains in the code and break them up when necessary to avoid possible slow down and performance issues. The hasOwnProperty is the most reliable method to check whether a property exists within an object or not. It's often recommended that hasOwnProperty is used in many cases when iterating over object properties. Although omitting the new keyword may result in some bugs, it's certainly not ideal to drop the use of prototypes altogether. In the end, we should be able to understand which solution is better suited for the needs of our application. In short, The JS Garden is an amazing resource that should be saved for future reference and understanding.

j-sm-n commented 7 years ago

Eloquent JavaScript Chapter 3: Functions

Eloquent JavaScript Chapter 5: Higher-Order Functions

Eloquent JavaScript Chapter 6: The Secret Life of Objects

Speaking JavaScript Chapter 17: Objects and Inheritance

JavaScript Garden

ghost commented 7 years ago

Eloquent JavaScript Ch.3

Eloquent JavaScript Ch.5

Eloquent JavaScript Ch.6

This chapter was very dense, and I will definitely need to re-read it. I'm still unclear about the nature of prototypes, although I'm inclined to analogize it to inheritance in Ruby (really not sure about that, though).

kctrlv commented 7 years ago

Functions

Defining a new vocabulary word to wrap a piece of a program in. Purpose is to reduce repetition and structure programs. Purpose is to reduce repetition and structure programs.

Definition

var addOne = function(x) {
  return x + 1;
};

console.log(addOne(2));
=> 3

Scoping

Possible to change global vars inside function.

var x = 'one'
var f1 = function() {
  var x = 'two'
}
f1();
// console.log(x) => 1

var f2 = function() {
  x = 'two'
}
f2();
// console.log(x) => 2

Shorter Declaration

function addOne(x) {
  return x + 1;
}

Function Declaration can be below the code that uses it

Arguments

Recursive

A useful principle is not to add cleverness unless you are absolutely sure you’re going to need it. It can be tempting to write general “frameworks” for every little bit of functionality you come across. Resist that urge. You won’t get any real work done, and you’ll end up writing a lot of code that no one will ever use.

alishersadikov commented 7 years ago

Eloquent Javascript Chapter 3: Functions

1) In other programming languages, a block of code between the braces produces a new local environment. But in Javascript, functions are the only things that create a new scope.

2) Function variables usually simply act as names for a specific piece of the program.

3) Optional Arguments: JavaScript is extremely broad-minded about the number of arguments you pass to a function. If passed too many, the extra ones are ignored. If passed too few, the missing ones will become 'undefined'. In this case, we can set the optional argument to a default value if it is not passed in.

4) A good mental model is to think of the function keyword as 'freezing' the code in its body and wrapping it into a package (the function value).

5) Assuming number is an integer: var numberString = String(number); will convert it to a string, like to_s in Ruby.

6) I thought declaring functions in the following two ways was equivalent:

    var f = function(a) { 
      console.log(a + 2); 
    };

    function g(a, b) { 
      return a * b * 3.5; 
    }

But apparently the former creates a function value f, hence the semicolon at the end. And the latter declares g to be a function.

Chapter 5: Higher-Order Functions

1) Functions that operate on other functions, either by taking them as arguments or by returning them, are called higher order functions. For example, you can have functions that create new functions, functions that change other functions, functions that provide new types of control flow.

2) JSON.stringify() - takes a JavaScript value and returns JSON-encoded string. JSON.parse() - vice versa.

3) The function is 'pure', if it does not modify/mutate the data(e.g.,array) it is given.

4) Some built-in methods for arrays in JavaScript: forEach, filter, map, reduce, every, some (need more exercises on these).

5) Although it is possible to write elegant code through abstractions, abstractions add layers between input and output which causes the computer to do more work.

6) Apply: functions have an 'apply' method that can be used to call them with an array specifying their arguments.

7) Binding: the bind method, which all functions have, creates a new function that will call the original function but with some of the arguments already fixed.

Chapter 6: The Secret Life of Objects

1) Methods are simply properties that hold function values.

2) 'this': object.method() { this }, 'this' is the object itself, like self.

3) Prototype: In addition to their set of properties, almost all objects also have a prototype. A prototype is another object that is used as a fallback source of properties. When an object gets a request for a for a property that it does not have, its prototype will be searched for the property, the the prototype's prototype, and so on. Object.prototype is the entity behind almost all objects, their great ancestral prototype.

4) Constructors: a more common way to create objects that derive from some shared prototype. In JavaScript, calling a function with the 'new' keyword in front of causes it to be treated as a constructor, so the object created with 'new' is an instance of the constructor. It is a convention to capitalize the names of constructors.

5) Enumberable vs. nonenumerable properties: all properties that we create by simply assigning to them are enumerable. The standard properties in Object.prototype are all nonenumerable and therefore do not show up in for/in loop, for instance.

6) Polymorphism: when a piece of code is written to work with objects that have a certain interface, any kind of object that happens to support this interface can be plugged into the code, and it will just work. Polymorphic code can work with values of different shapes, as long as they support the interface it expects.

7) Using a variable name starting with an '_' or consisting entirely entirely of a single underscore is a way to to indicate that this argument is not going to be used.

Speaking JavaScript Chapter 3: The Nature of JavaScript JavaScript is:

Chapter 17: Objects and Inheritance

Layers of OOP in JS:

  1. Object-orientation with single objects;
  2. Prototype chains of objects;
  3. Constructors as factories for instances, similar to classes in other languages;
  4. Subclassing - creating new constuctors by inheriting from existing ones.

    Layer 1: Single Objects

    • All objects in JS are maps from strings to values.
    • A key/value entry in an object is called property.
    • The key of a property is a text string.
    • The value of a property can be any JS value, including a function.
    • Methods are properties whose values are functions.

    Three kinds of properties:

    1. Properties (or named data properties): normal properties in an object - mappings from keys to values; methods; most common kind.
    2. Accessors (or named accessor properties): getter and setter properties; sort of virtual properties; allow to compute the values of properties.
    3. Internal properties: exist in ECMAScript lang specification; not directly accessible; accessible via Object.getPrototypeOf().

    Object Literals

    • allow you to directly create plain objects;
      var jane = {
      name: 'Jane',
      describe: function () {
        return 'Person named '+this.name; 
      },  
      };

    Based on the above example:

    • jane.name => 'Jane' // dot operator can only access properties whose keys are identifiers
    • jane.describe => [Function]
    • jane.descirbe() => 'Person named Jane' // calls that method
    • jane.name = 'John'; // sets property name
    • delete jane.name // deletes the property(the whole key-value pair)

    Delete only affects direct, noninherited properties, without touching the prototypes.

    Bracket operator coerces its interior to string:

    var obj = { '6': 'bar' };
    > obj[3+3]  // key: the string '6'
    'bar'

    An empty object literal is almost always a better choice than the constructor:

    var obj = new Object(); // avoid
    var obj = {}; // prefer

    Layer 2: The Prototype Relationship Between Objects

    • this relationship is about inheritance: every object can have another object as its prototype.

    The following code creates objects jane and tarzan that share the prototype PersonProto:

    var PersonProto = {
      describe: function () {
          return 'Person named '+this.name;
      }
    };
    var jane = {
      name: 'Jane'
    };
    var tarzan = {
      name: 'Tarzan'
    };
    • Sealing: prevents extensions and makes all properties 'unconfigurable';
    • Freezing: makes all properties non-writable and seals obj.

    Layer 3: Constructors - Factories for Instances

    • A constructor function or constructor helps with producing objects that are similar in some way.
    • 'use strict'; in the constructor allows you to get exception if something goes wrong, instead of failing silently.

    Layer 4: Inheritance Between Constructors

    • Yes, such inheritance is possible.
bradgreen3 commented 7 years ago

Chapter 3 (Speaking): The Nature of JavaScript

Chapter 3 (Eloquent): Functions

Chapter 5 (Eloquent): Higher Order Functions

Chapter 6: (Eloquent) The Secret Life of Objects

Chapter 17: Objects and Inheritance (Speaking JavaScript)

Javascript Garden

bermannoah commented 7 years ago

Chapter 3 (Speaking) The Nature of Javascript

Chapter 3 (Eloquent) Functions

Chapter 5 (Eloquent) Higher-Order Functions

Chapter 6 (Eloquent) The Secret Life of Objects

Chapter 17 (Speaking) Objects + Inheritance

bfpepper commented 7 years ago

We can't get away from Javascript. It's everywhere. You can declare a function by var <name>(){}; or function <name>(){}. Has similar scope as Ruby. Can accept any number of arguments. If there are more arguments they are simply ignored, if there are too few the remaining are "undefined." We can nest functions within each other. In this case the main function will "freeze" and get the return function(...){...} will then get its necessary info to execute and then the rest of the function will continue. JS loves SRP as much as Ruby. For arrays we still have access to functions like reduce, map, forEach, for, etc. this is analogous to self in Ruby. new <constructorName> == Class.new in Ruby.

JStans12 commented 7 years ago

Chapter 3 (Speaking) The Nature of Javascript

Chapter 3 (Eloquent) Functions

Chapter 5 (Eloquent) Higher-Order Functions

Chapter 6 (Eloquent) The Secret Life of Objects

Chapter 17 (Speaking) Objects + Inheritance

m-scherer commented 7 years ago

Speaking Javascript

Chapter 3. The Nature of Javascript

Chapter 17. Objects and Inheritance

Eloquent Javascript

Chapter 3

Chapter 5

Chapter 6

NZenitram commented 7 years ago

Chapter 3. The Nature of JavaScript

Chapter 3 (Eloquent): Functions

Chapter 5 (Eloquent): Higher Order Functions

Chapter 6: (Eloquent) The Secret Life of Objects

Chapter 17: Objects and Inheritance (Speaking JavaScript)

JavaScript Garden

dshinzie-zz commented 7 years ago

Chapter 3 (Eloquent): Functions JavaScript scopes variables depending on where they are created Prototypes are used to add methods and properties to objects Functions can be stored as values Being able to reference a specific instance of local variables in an enclosing function is called closure. Functions can be roughly divided into those that are called for their side effects and those that are called for their return value

Chapter 5 (Eloquent): Higher Order Functions Abstractions hide details and give us the ability to talk about problems at a higher (or more abstract) level. Functions that operate on other functions, either by taking them as arguments or by returning them, are called higher-order functions. The map method transforms an array by applying a function to all of its elements and building a new array from the returned values. Higher-order functions start to shine when you need to compose functions.

Chapter 6: (Eloquent) The Secret Life of Objects Methods are simply properties that hold function values. A prototype is another object that is used as a fallback source of properties. A more convenient way to create objects that derive from some shared prototype is to use a constructor. A prototype can be used at any time to add new properties and methods to all objects based on it. When a piece of code is written to work with objects that have a certain interface—in this case, a toString method—any kind of object that happens to support this interface can be plugged into the code, and it will just work. This technique is called polymorphism—though no actual shape-shifting is involved. Polymorphic code can work with values of different shapes, as long as they support the interface it expects.

Chapter 17: Objects and Inheritance (Speaking JavaScript) The value of a property can be any JavaScript value, including a function. Methods are properties whose values are functions. JavaScript’s object literals allow you to directly create plain objects (direct instances of Object)

jbkimble commented 7 years ago

Chapter 3: The Nature of Javascript

* Some quirks unique to javascript are: it has no integers, only floats. It has no built-in modules.
* Javascript is a dynamic, dynamically typed, functional and object-oriented programming language which fails silently and is an essential part of the web platform

Eloquent Javascript Chapter 3:

* Functions are like the words in your vocabulary, they allow you to do work.
* Variables defined inside of functions are only accessible with that function
* Variables initially declared outside of a function have a global scope
* Functions can be created inside of other functions.  These functions each have their own individual variable scope and access to the variables of the ‘parent’ functions which wrap them
* Control flow - the order the machine executes the code
* With ‘function declaration’ short hand you can define functions which are moved to the top of the control flow and thus can be called above where they are declared
* Call Stack - The order of the control flow and where in the code the computer should jump to next, the call stack takes memory which can be overloaded in which case you will get an error
* You can create functions with variable numbers of arguments, if you pass to many arguments to a function the get ignored, if you pass to few the unassigned arguments get set equal to ‘undefined’

Eloquent Javascript Chapter 5:

* Pure function - given the same attributes will always produce the same results
* Higher order functions - functions that operate on other functions either by taking them as arguments or by returning them
* Javascript has a map methods map(array, transformMethod(()) which returns an array with every element transformed
* It also has a reduce function which computes a single value from an array
* Nested loops can be a source of series slow down in your program
* ‘bind’ method - creates a new function that will call the original function but with some the arguments already fixed

Eloquent Javascript Chapter 6:

* Objects act as a simple interface for programmers to interact with
* prototype: another object that is used as a fallback source of properties.  You can create an object with a specific photo type which can contain function and state ubiquitous to all objects with that prototype.
* If you add a property to an object who's prototype has the same name the objects property will store the value but the prototype will remain unchanged.  Prototype property values could show up when enumerating through an object, to avoid that we should define our properties as ‘non-enumerable’
* Sometime prototypes get in the way, you can create objects without prototypes
* Constructors: Use new keyword to create a new object / ‘instance’ of its constructor.  Constructors are capitalized to distinguish them.
* polymorphism - methods with same names in different classes doing similar things
* you can use the ‘get’ and ‘set’ key words to specify a function to be run when the associated property is read or written
* you can use inheritance to allow one function to access the functions of another class

Chapter 17: Object and Inheritance

* object literals - plain direct instances of object (with state and behavior)
* .nameOfVar - . operator for reading properties
* numbers can be used as property values but they will be interpreted as strings
* You sometimes have to convert a value into an object
* ‘this’ is always a parameter that comes with a method, it represents the object on which the method has been called.  its value is ‘undefined’
* you can protect objects in three ways (preventing extensions: making it impossible to add properties to an object, sealing: making all the properties unchangeable, freezing: makes all properties permanently read only
* You can have constructors inherit one another prototype properties as well
* There are not that many generic methods in Javascript, most are around arrays and strings

Javascript Garden

* Everything but null and undefined acts like an object in javascript
* hasOwnProperty is the only reliable method to check for the existence of a property on an object
* loops can iterate over the prototype chain what iterating over the properties of an object, therefore you have to filter out unwanted properties side the loop body
* closures: functions insides of other functions have access to the scope of the ‘parent’ functions which wrap them.
* every function in javascript has a special variable called ‘arguments’ which is an object with a list of all arguments passed to that function, you can convert this object into an array
meganft commented 7 years ago

Speaking JS: Chapter 3

Eloquent JS Ch. 3: Functions

Chapter 5 (Eloquent): Higher Order Functions

Chapter 6 (Eloquent): The Secret Life of Objects

Chapter 17(Speaking): Objects and Inheritance

Javascript Garden

annadolan commented 7 years ago

Chapter 3 (Speaking)

Chapter 3 (Eloquent)

Chapter 5 (Eloquent)

Chapter 6 (Eloquent)

Chapter 17 (Speaking)

JavaScript Garden will probably be the most helpful of all of these - it clarifies a lot of the things I didn't understand in the chapters. This will be a really helpful reference.

AliSchlereth commented 7 years ago

Chapter 3(Speaking): Quirks: No int, arrays are not technically indexed, but map btwn # & element Elegances: First class functions, closures, prototypes, object literals, array literals

Chapter 3(Eloquent): Lexical Scoping: Sometimes referred to as Static Scoping. Access to variable in outer scope/function and own function. Let vs Var: Let creates a variable local to the block not the function Arguments: Won't throw an error, ignore too many, set as undefined for too few Closures: ... ?? Being able to reference a specific instance of local variables in an enclosing function ... ?? Looping vs Recursion: Looping is faster but recursion is more elegant, Worry about readability first though.

Chapter 5(Eloquent): Higher-Order Functions: Pass functions into other functions. Var declared inside inner isn't available in out function here. forEach, map, filter, reduce: All available, similar to Ruby enumerables. Looping is faster but less readable than these. forEach, map, and filter can take a second argument for index. apply: within body of a function, will apply function for each arg not just first bind: available on all functions, partially applied version of the function

Chapter 6(Eloquent): Objects!! Prototypes: another object that is used as a fallback source of properties. Look-up chain, inherits from parent generations properties Constructors: new => constructor, provides this = newObj, creates instances, the prototype of a constructor is Function.prototype no Object.prototype. A constructor's prototype property is the instances of the constructor, not is's prototype(Function.prototype). Can overwrite a property locally.
Array.prototype.toString !== Object.prototype.toString Properties we create are enumerable, but can set that to false with .defineProperty. hasOwnProperty checks if property is of the object not its prototype Polymorphism: code that works w/ different types of values i.e. toString instanceof: checks inheritance line

Chapter 17(Speaking): Methods vs Properties: properties are key:value methods are key: fuction delete obj.hello: returns t/f use sparingly use obj = {} vs obj = new Object Strict Mode and Callbacks: I'll need to learn more about this. .call: jane.prototype.call(jane, 'Tarzan') .apply: call w/ array of arguments .bind: sends along params to new function .construct: .bind.apply() for-in: avoid when iterating over own code protecting obj: .preventExtensions, .seal, .freeze

Garden: This is a good review of everything that has been covered.

epintozzi commented 7 years ago

Chapter 3. Speaking - The Nature of JavaScript • It's dynamic- can easily be changed and manipulated • It is both functional and object-oriented • It's error messages can be ambiguous, if they are event present • It is compiled by javascript engines after the source code is deployed • Though typically used directly in browser, it can be used without (ex: node.js) • It's creation takes influence from java, perl, awk, hypertalk, scheme, and self

Chapter 3. Eloquent JavaScript - Functions • Functions are just variables set to equal the function itself • Functions can take many parameters or no parameters • Functions can be created inside of functions, where, those results remain local to the nested function • Declaration notation can be used (rather than defining a function as a variable); when this is done, the function does not have to be at the top of the page/declared before it is used. Declaration notation should not be used with nested functions. • You can pass as many arguments as you want in JS, but if you pass too many, the extras will just be ignored.

Chapter 5. Eloquent JavaScript - Higher Order Functions • More lines doesn't mean a better program • Using abstractions can make code simpler and easier to understand as the program grows and changes hands • Higher order functions are just functions that create, change, or return other functions • The JSON format is a commonly used format for communicating and storing data but you can't use variables or functions within. • Filter, forEach, map, reduce, are standard methods for arrays • We can compose functions for greater clarity and abstraction • Using these built-in methods can significantly slow down programs however so we have to weigh the cost of abstraction against the cost of performance

Chapter 6. Eloquent JavaScript - The Secret Life of Objects • Prototypes sound a lot like Ruby classes to me, based on the description in this chapter • Constructors seem similar to initializing a object via a class in ruby by using new • Object properties can be overridden for specific derivatives of that object • Polymorphism adjusts an object or value to match a specified property without being destructive • Getters and setters are used to read and write properties on objects • Inheritances can be used to override properties of instances of prototypes but the use of them is controversial

Chapter 17. Speaking - Objects and Inheritance • There are 4 layers of objects in JS: single objects, prototype chains of objects, constructors, and subclassing • All objects are dictionaries (like a hash) where every key/value pair is a property. Keys are always strings and values can be anything. • Named properties are most common where the string key points to a value. Accessors (getters/setters) are a second type of property. Internal properties also exist but are generally only accessible via the getPrototypeOf method • Use the "dot" to call methods, access properties, and get/set or delete properties • Methods can also be called with the bracket operator • This chapter reviews a lot of what was covered in Chapters 5 and 6 of Eloquent JavaScript, though with a few more thorough examples. • Section 2 has a nice summary of best practices for iterating through properties and enumerating • Defining a property is creating a new property whereas assigning a property is changing an existing property • Properties can be protected with various methods which determine how or if they can be altered • The later half of this chapter will need to be reviewed and re-read several times as I better understand Javascript; This portion of the chapter will be great to reference as I work with constructors and inheritance

Javascript Garden • Right off the bat, this will be a great resource to keep around as it is a little clearer and more succinct than the chapters above. Especially while starting out, I think this is the most useful tool I've read through so far. • All objects in js are technically hash maps or dictionaries so I would access properties just as I would a hash in ruby. • Good recap of functions- what they are and how to use • Also good recap of this which often confuses me; Come back to this section! • Overall good quick lookup type resource

antciccone commented 7 years ago

Module 4 Intermission Assignments

Readings

  1. The Nature of JavaScript Key Takeaways -no build in modules -Object Oriented and functional -JavaScript has been influenced by many languages like java, perl, python etc

Functions

Minimum function min(num1, num2){ if (num1 > num2) return num1; } else { return num2; }

Recursion function isEven(num){ if (num === 0) return true; } else if { num < 0 return false; } else { num - 2; isEven(num); } console.log(isEven(50)); -> true console.log(isEven(75)); -> false console.log(isEven(-1)); -> false

Bean Counting function countBs(string){ var counter = 0; for (var i = 0, i < string.length, ++) counter ++ if ( i === “B”); return counter; } console.log(countBs("BBC")) -> 2

function countChar(string, letter) { var counter = 0 ; for (var i = 0, string.length, ++) counter ++ if ( i === letter); return counter; } console.log(countChar("kakkerlak", "k"))

Higher order Functions

-Abstractions hide details and give us the ability to talk about problems at a higher level. -Higher order functions operate on other functions either by taking them as arguments or returning them -Reminder - JSON = javascript object notation what -reduce :)

The Secret Life of Objects

-methods are simply properties that hold function values -almost all object have a prototype or another object that is used as a fallback source of properties -calling a function with the ‘new’ keyword in front of it causes it to be treated as a constructor

JavaScript Garden -great resource for common javascript problems. It also has easy to read samples.

vidoseaver commented 7 years ago

Eloquent Javacsript

Chapter 3: Data structures, object and arrays

Chapter 5: Functional Programming

Chapter 6: Object Oriented Programming

Javascript Garden

rtravitz commented 7 years ago

Chapter 3 (Speaking): The Nature of JavaScript

Chapter 3 (Eloquent): Functions

Chapter 5 (Eloquent): Higher Order Functions

Chapter 6: (Eloquent) The Secret Life of Objects

Chapter 17: Objects and Inheritance (Speaking JavaScript)

JavaScript Garden

Cdunagan05 commented 7 years ago