O'Reilly logo

JavaScript: The Good Parts by Douglas Crockford

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

A Simple Testing Ground

If you have a web browser and any text editor, you have everything you need to run JavaScript programs. First, make an HTML file with a name like program.html:

<html><body><pre><script src="program.js">
</script></pre></body></html>

Then, make a file in the same directory with a name like program.js:

document.writeln('Hello, world!');

Next, open your HTML file in your browser to see the result. Throughout the book, a method method is used to define new methods. This is its definition:

Function.prototype.method = function (name, func) {
    this.prototype[name] = func;
    return this;
};

It will be explained in Chapter 4.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required