JAVASCRIPT

 Home  Computers & Internet  Web Programming JAVASCRIPT
What is Javascript?
Javascript Placement
Syntax
Reserved Words
Variables
Data Types
Escaping Characters
Concatenation
Arithmetic Operators
Assignment Operators
Comparison Operators
Boolean Operators
Conditional Operator
If Statements
Else If Statements
If Else Statements
Switch Statements
While Loops
For Loops
Do While Loops
Break Statement
Continue Statement
prompt()
alert()
Date()
Event Handlers
String Object Methods
Math Object Methods
Window Object Methods

ESCAPING CHARACTERS IN JAVASCRIPT

Certain characters after a backlash \ have a special effect in the javascript code. This is referred to as the escape sequence.

Some of these characters are:

\n

Characters after it start on a new line.

Example:

var string="Go on, make \n my day";

alert(string);

The above outputs:

Go on, make
my day

\t

Horizontal tab space immediately after.

Example:

var string="Go on, make\t my day";

alert(string);

The above outputs:

Go on, make       my day

\r

Carriage return immediately after.

Example:

var string="Go on, make\r my day";

alert(string);

The above outputs:

Go on, make
my day

\'

Single quote. Useful in single quoted strings without causing the string to terminate prematurely.

Example:

var string='Go on, \'make my\' day';

alert(string);

The above outputs:

Go on, 'make my' day

\"

Double quote. Useful in double quoted strings without causing the string to terminate prematurely.

Example:

var string="Go on, \"make my\" day";

alert(string);

The above outputs:

Go on, "make my" day

\\

Single backslash. Allows you to literally insert a backslash character.

Example:

var string="Go on, \\make my day";

alert(string);

The above outputs:

Go on, \make my day

Other special characters:

\f - form feed
\b - backspace

Home | Privacy Policy | Terms Of Use | Contact Us