WebFund 2016W Lecture 6

From Soma-notes
Revision as of 17:33, 26 January 2016 by Soma (talk | contribs)
Jump to navigation Jump to search

Video

The video from the lecture given on January 26, 2016 is now available.

Notes

In-class Notes

Lecture #6
---------

PLAN
* Assignment 2
  - aliases
  - headers
  - other clarifications?

* Objects
  - associative hashes with inheritance
  - prototypes using Object.create
  - "global" object
  - "Object" object
  - Object.prototype
  - hasOwnProperty and Object.hasOwnProperty

* Function calling and "this"
 - functions in regular scope
 - methods
 - constructors with new
 - call/apply
 - functions in global scope

* form demo!

------------------

If a function starts with a capital letter, it is an object
constructor that you call with new.
 - why?  because it keeps JavaScript programmers sort of sane

if (x.a) { blah}     instead do 

if (x.hasOwnProperty(a) && x.a) better, but

if (hasOwnProperty.call(x,a) && x.a) is even better

Why not tinywebserver?

* templates: otherwise, have to manually generate web pages using
  variable data
* routing: otherwise, you'll be using regexp's to match each 
  incoming URL and then call the right function