[home] [PDF Version]

Practical Javascript : Fixing common bugs

Note: This is just an outline - i'll get around to writing this at some point, honest.

Mis-spelling a variable name

	var bob = 10;
	if (bbo == 10) alert('ok!');

Using a single equals instead of a double equals

	var bob = 10;
	if (bob = 9) alert('not ok!');

Overshooting Iterators

	for(var i=0; i<=list.length; i++){
		do_something(list[i]);
	}

Infinite Iterators

	for(var i=0; i<10; i++){
		i--;
	}

Side effects

	var b = a++;