WebFund 2015W Lecture 10

From Soma-notes
Revision as of 17:42, 4 February 2015 by Soma (talk | contribs) (→‎CORRECTION)

Resources


Video

The video from the lecture given on February 4, 2015 is available now as an MP4.

Notes

CORRECTION

In lecture we saw that we could break notes-demo by giving hasOwnProperty as a username. This error is because the following code in the login post handler is incorrect:

    if (!userNotes[username]) {
	userNotes[username] = [];
    }

This code should instead say:

   if (!userNotes.hasOwnProperty(username)) {
       userNotes[username] = [];
   }

If you are treating a JavaScript object as an associative array you must explicitly check whether a given key value (property) is present using the hasOwnProperty() method inherited by every object.

Note you can create an object x with no prototype by doing the following: