005 JSJ Javascript Objects




    • Objects are basically hashmaps
    • Calling ‘new'
    • Constructors
    • Javascript creates an empty object and hands it off to the constructor
    • Functions are sort of like classes
    • ES5 (strict mode)
    • arguments.callee
    • Old SproutCore used arguments.callee to implement super
    • Prototypes
    • The new object inherits the function's prototype
    • Prototypes are referenced, not copied
    • Don't monkey with Object.prototype
    • Should you override native prototypes?
    • Object.keys vs for x in y
    • Premature optimization
    • Property iteration
    • Namespaces
    • es-discuss
    • 3 paradigms
      • new
      • literals
      • function newX()
      • Object.create(prototype) (contributed by Yehuda in the backchannel)
    • Data privacy
    • jQuery uses the prototype system
    • Don't be over obsessed with privacy
    • Functions create closures
    • Closures carry the context they were created in
    • Scoped variables in closures are also referenced, not copied. So, changes to those variables are reflected to everything else in that scope.
    • Closures can make memory management and scoping problems worse, but are generally a good thing
    • Waterfall pattern: keep functions in the same scope/indentation level and call the next when one finishes
    • Array syntax creates an object that inherits a specific prototype
    • Object keys can only be a string
    • How to think about OO
    • EMCAScript 5 Objects and Properties
    • Closure in action
    • More issues with closures
    • Add behaviors to objects or static clases with ‘mix'
    • Code example – Prototypeal Inheritance
    • Understanding JavaScript Function Involcation and ‘this'