JavaScript Basics

Syntax Basics

Understanding statements, variable naming, whitespace, and other basic JavaScript syntax.

Example 2.1: A simple variable declaration
var foo = ‘hello world’;

Example 2.2: Whitespace has no meaning outside of quotation marks
var foo = ‘hello world’;

Example 2.3: Parentheses indicate precedence
2 * 3 + 5; // returns 11; multiplication happens first
2 * (3 + 5); // returns 16; addition happens first

Example 2.4: Tabs enhance readability, but have no special meaning
var foo = function() {
console.log(‘hello’);
};

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s