The SitePoint Forums have moved.

You can now find them here.
This forum is now closed to new posts, but you can browse existing content.
You can find out more information about the move and how to open a new account (if necessary) here.
If you get stuck you can get support by emailing forums@sitepoint.com

If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Simply javascript and element's class attributes functions...

I noticed that when in the book the author write functions (in the Core book library) that for example add classes to the html element "class" attribute or remove them etc in the function code it doesn't check first if the class attribute is present on that element. If it isn't present i think the element node reference property (in the javascript code) that try to access that class html attribute will return "null" and the code doesn't control this event.

Another thing. In the book it is said that it is more appropriate and secure to declare/assign variables always with the "var" keyword expecially inside function so we can mantain the local scope in which the variable was declared. Then on the chapter that talks about events on page 125 for example, the author assign a value to a variable called "event" but without the "var" keyword. Is the author creating a global variable here inside this function?