adequately good

decent programming advice

written by ben cherry




Performance of === vs. ==

One particular weirdness and unpleasantry in JavaScript is the set of equality operators. Like virtually every language, JavaScript has the standard ==, !=, <, >, <=, and >= operators. However, == an...

Minimum Timer Intervals in JavaScript

I was talking with a co-worker today about the behavior of setTimeout and setInterval when given a small interval, like 0 or 1. The expectation would be tha...

Finding Improper JavaScript Globals

When I interview web developers, my first JavaScript question is usually the following:

What is the difference, in JavaScript, between x = 1 and var x = 1. Feel free to answer in as much ...

JavaScript Scoping and Hoisting

Do you know what value will be alerted if the following is executed as a JavaScript program?

var foo = 1;
function bar() {
	if (!foo) {
		var foo = 10;
	}
	alert(foo);
}
bar();

If it surprises you that the answer is “10”, then this one will probably really th...

go previous or next