The Computer Chess Blog documents the creation of a C# chess engine. It's not JavaScript but the syntax is similar enough that you might get a good understanding of the different chess engine components.
Also if you want your chess engine to be web enabled you might want to consider using C# with a Silverlight GUI. You will get better performance from .NET than you would with JavaScript. As you will learn this will translate into a stronger (deeper searching) chess program. A good example of Silverlight Chess can be found at GeeksWithChess.com