Skip to content

Instantly share code, notes, and snippets.

@stevepentler
Last active March 17, 2016 20:31
Show Gist options
  • Save stevepentler/7e7097291fb32cc8ab31 to your computer and use it in GitHub Desktop.
Save stevepentler/7e7097291fb32cc8ab31 to your computer and use it in GitHub Desktop.
Speaking Javascript Chapters 3, 15, 16, 17

Which sections were interesting?

  • Why JS is okay with "failing silently"? But seriously, WHY?
  • Constructors. Are these the equivalent of a class in Ruby?
  • How common is it to create sad paths to throw an error within a function?
  • Dynamic relationships seem like they could get convoluted quickly and create some very dependent code.

Which sections did you totally skim?

  • I read everything except for CH17, see below...

Do you think the reading was valuable?

  • Chapter 17 was intimidating, which led me to skim most of it. I'd much rather read Eloquent JS or something else than a super long web page. At this point I can only retain the high level ideas, so when I see an extremely detailed lengthy web-page, I know my time will be better spent elsewhere.

Which topics were notably confusing?

  • Hoisting: Is this to say that variables and necessary functions are defined before they are called? ie: You can call functions anywhere within a file, and it knows to prioritize the definition of variables and methods first?
  • I don't understand why you need to pass in null when using apply & bind. Is this saying that if the number of arguments inserted do not align with the function, insert null for whatever the final value is? Basically a default? It seems like this would get really tricky if you had multiple optional arguments, or slip up on the argument order.
Chapter 3
  • I still don't have a great understanding of what functional programming means.
  • "fails silently" is still the most frustrating part, need to learn how to debug
Chapter 15: Functions
  • Constructors seem to be like new classes? ex: new Date()
  • methods end with parenthesis obj.method()
  • parameters are "placeholders" to define a function ex: (number1, number2), arguments are the actual values that are passed in ex: (3, 7)
  • ALL FUNCTIONS ARE OBJECTS, instances of Function and return a function object
  • call(), apply(), and bind() are methods that all functions have (remember that functions are objects and therefore have methods).
  • function foo(mandatory, optional) { if (mandatory === undefined) { throw new Error('Missing parameter: mandatory'); } }
  • function bar(arg1, arg2, optional) { if (optional === undefined) { optional = 'default value'; } }
  • naming parameters selectEntries({ start: 3, end: 20, step: 2 });
Chapter 16: Variables, Scopes, Environments, & Closures
  • Dynamic Relationship: When one function is called, it can invoke another
  • If global and local variable with same name, local "blocks" global
  • If you don't declare a variable with var, it defaults to global
Chapter 17:
  • key value relationship is called a property
  • key is always a text string
  • named properties
    • normal properties, most common
  • accessors
    • getters and setters
  • internal properties
    • Prototype, accessed indirectly ?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment