JavaScript
Understanding variables
Most programs use variables. This lesson explains what variables are.
Common JavaScript Errors
Here are some common errors people make in JavaScript.
The number of elements in a JavaScript array: length is misleading
The JavaScript property length returns the number of elements in an array. Right? Er, well, ...
Changing text
Learn some more JavaScript/jQuery:
- Learn how to set the text of an element, with
text("stuff"). - Learn how to get the text of an element, with
text(). - Learn how to add a CSS class to an element, with
addClass(). - Learn how to remove a CSS class from an element, with
removeClass().
SitePoint reference
Good reference for HTML, CSS, and JavaScript.
Programs in browsers
In this lesson, you will learn that:
- Some programs run inside browsers.
- Those programs are downloaded along with pages.
- Every major browser can run JavaScript programs.
- Programs are triggered by events.
- JavaScript is used for interface effects, validating form data, input widgets, and sending data to a server.
Finding JavaScript bugs
Learn:
- Syntax bugs happen when you type something the browser doesn’t understand, like
alrt().
- Use Firefox’s error console to track down syntax errors.
- Logic errors are when you tell the browser to do the wrong thing.
- Use
alert()statements to track program execution. Ifalertmessages are supposed to show up, but don’t, you know what code is not executing.
- Use
alert()statements to look at the values of variables.
Better client-side error display
Learn:
- How to report errors in a professional way.
- How page-wide, global error messages help the user.
- How JavaScript functions make error reporting easier to program.