Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Advanced Javascript Basics

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.

Advanced Javascript Basics

Avatar for Lauren Voswinkel

Lauren Voswinkel

June 25, 2014
Tweet

More Decks by Lauren Voswinkel

Other Decks in Programming

Transcript

  1. Environments • Variable environments are defined during parsing (before execution)

    • Environments all contain references to their parent scope
  2. Environments • Variable environments are defined during parsing (before execution)

    • Environments all contain references to their parent scope • Variables defined higher up the chain have a broader domain, but a lower priority
  3. Environments • Variable environments are defined during parsing (before execution)

    • Environments all contain references to their parent scope • Variables defined higher up the chain have a broader domain, but a lower priority • Namespaces are your friend.
  4. Environments • Variable environments are defined during parsing (before execution)

    • Environments all contain references to their parent scope • Variables defined higher up the chain have a broader domain, but a lower priority • Namespaces are your friend. • No really, namespace collisions are confusing and terrible
  5. .call() and .apply() • allows execution of function with any

    environment • methods are executed with the object their associated with as their default environment
  6. .call() and .apply() • allows execution of function with any

    environment • methods are executed with the object their associated with as their default environment • .call() accepts arguments individually
  7. .call() and .apply() • allows execution of function with any

    environment • methods are executed with the object their associated with as their default environment • .call() accepts arguments individually • .apply() accepts arguments as an array or
 array-like object
  8. arguments • functions have a length • length is equal

    to number of named arguments
 (the function’s arity)
  9. arguments • functions have a length • length is equal

    to number of named arguments
 (the function’s arity) • all arguments, even accounted ones are available in arguments object
  10. arguments • functions have a length • length is equal

    to number of named arguments
 (the function’s arity) • all arguments, even accounted ones are available in arguments object • unaccounted arguments can be discerned by using Array.slice with arguments’ as the context
  11. "Classes" • JavaScript doesn't have traditional classes • JavaScript "classes"

    are objects with two requirements: • Constructor Function
  12. "Classes" • JavaScript doesn't have traditional classes • JavaScript "classes"

    are objects with two requirements: • Constructor Function • Prototype
  13. new

  14. Overview • Environments & Environment Hierarchies
 - scopes
 - var

    keyword
 - hoisting
 - variable lookup • Functions as "First-Class" Objects
 - closures vs. pure functions
 - currying
 - partial application
 • Callbacks & Avoiding Callback Pyramids
 - callbacks, in principle
 - callbacks that use callbacks
 - avoiding callback pyramids (why are they necessary?)
  15. Overview (cont'd) • .call() & .apply()
 - passing environment contexts


    - arguments object • Prototypal Programming
 - Constructors
 - Constructor Methods
 - Instance Methods • Object Oriented Approaches
 - Inheritance
 - Prototype chaining