Syntax Basics

Contact Us or call 1-877-932-8228
Syntax Basics

Syntax Basics

We will cover understanding statements, variable naming, whitespace, and other basic JavaScript syntax.

A Simple Variable Declaration

var foo;
var bar = 'hello world';

The first line creates a variable with no defined value. In JavaScript, this results in a special value, undefined. The second variable is initialized to a string value.


Whitespace has no meaning outside of quotation marks:

var foo =
	'hello world';

Tabs enhance readability, but have no special meaning:

var foo = function(a) {
	if (a < 10) {


There are two types of comments: block comments and comments-to-end-of-line:

var x = 3;   // double slash is comment to end of line

		This is a block comment