GoConqr has a new look! Let us know what you think.

Notes

Getting Started

Deepak Kumar Core JavaScript Intermediate English 1 page

Content of the notes (1)

Page 1

JavaScript is case-sensitive and uses the Unicode character set. In JavaScript, instructions are called statements and are separated by a semicolon (;). It is recommended to always add semicolons to end your statements; it will avoid side effects.

Spaces, tabs and newline characters are called whitespace. The source text of JavaScript scripts gets scanned from left to right and is converted into a sequence of input elements which are tokens, control characters, line terminators, comments or whitespace.

Comments

The syntax of comments is the same as in C++ and in many other languages:

// a one line comment /* this is a longer, multi-line comment */ /* You can't, however, /* nest comments */ SyntaxError */

Variables

You use variables as symbolic names for values in your application. The names of variables, called identifiers, conform to certain rules.

A JavaScript identifier must start with a letter, underscore (_), or dollar sign ($); subsequent characters can also be digits (0-9). Because JavaScript is case sensitive, letters include the characters "A" through "Z" (uppercase) and the characters "a" through "z" (lowercase).

There are three kinds of declarations in JavaScript:

var : Declares a variable, optionally initializing it to a value.

let : Declares a block scope local variable, optionally initializing it to a value.

const : Declares a read-only named constant.

You can declare a variable in three ways:

With the keyword var. For example, var x = 42. This syntax can be used to declare both local and global variables.

By simply assigning it a value. For example, x = 42. This always declares a global variable, if it is declared outside of any function. It generates a strict JavaScript warning. You shouldn't use this variant.

With the keyword let. For example, let y = 13. This syntax can be used to declare a block scope local variable. See Variable scope below.

Note: A variable declared using the var or let statement with no initial value specified has the value undefined. An attempt to access an undeclared variable will result in a ReferenceError exception being thrown. The undefined value behaves as false when used in a boolean context.

Information

Description
Getting Started with JavaScript
Created by
Deepak Kumar
Views
23
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?