Chapter 3. JavaScript Basics

You can't run without walking first. If you've programmed before, you probably won't need to be told what a variable is, and one look at a function declaration and you'll understand what that's all about too. Even if this applies to you, you'll still want to read this chapter because some properties of the language are quite distinct from those of Java, C, Perl, or C#. If you are new to programming or are seeing some of these building block concepts for the first time, not to worry. This chapter introduces all the language fundamentals as straightforwardly as possible. Soon they'll be second nature to you.

General Characteristics

I'll begin our discussion of the language with a broad overview of the most basic characteristics of the language.

A Dynamic Language

A dynamic programming language can execute at runtime behaviors that other languages might perform when they are compiled. Some of these behaviors include extending the program by parsing new source code, modifying objects and classes, or modifying the type system. Dynamic typing, which is when type-checking mainly happens at runtime instead of compile-time, is another related concept (and also something that JavaScript does) but is not necessary for a language to be called dynamic.

Some specific attributes make JavaScript dynamic and also make it extremely flexible. These are:

  • Eval: An evaluation expression is something that allows us to introduce new source code to the program at runtime. By enclosing ...

Get JavaScript® Programmer's Reference now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.